NNET Procedure
Getting Started: NNET Procedure
Note: Input data must be in a table that is accessible in your session. You can refer to this table by using a two-level name. The first level is a libref, and the second level is the table name. For more information, see the section Using SAS Viya Workbench in Chapter 2, Shared Concepts.
This example shows how to use the NNET procedure to train a neural network to predict the type of iris plant. The iris data published by Fisher (1936) have been widely used for examples in discriminant and cluster analyses. The sepal length, sepal width, petal length, and petal width are measured in millimeters on 50 iris specimens from each of three species: Iris setosa, I. versicolor, and I. virginica. The data set is available in the Sashelp library.
You can load the sashelp.iris data into your SAS library by naming your SAS library in the first statement of the following DATA step:
data mylib.iris;
set sashelp.iris;
run;
These statements assume that your SAS library is named mylib, but you can substitute any appropriately defined SAS library.
The following statements run PROC NNET and output the results to ODS tables:
proc nnet data=mylib.iris;
input SepalLength SepalWidth PetalLength PetalWidth;
target Species / level=nominal;
hidden 2;
train outmodel=mylib.nnetModel_gs seed=635117188;
partition fraction(validate=0.3 seed=103873735);
run;
Figure 1 shows the model information for the neural network.
Figure 1: Model Information
| Model Information | |
|---|---|
| Model | Neural Net |
| Number of Observations Used | 93 |
| Number of Observations Read | 93 |
| Target/Response Variable | Species |
| Number of Nodes | 9 |
| Number of Input Nodes | 4 |
| Number of Output Nodes | 3 |
| Number of Hidden Nodes | 2 |
| Number of Hidden Layers | 1 |
| Number of Weight Parameters | 14 |
| Number of Bias Parameters | 5 |
| Architecture | MLP |
| Seed for Initial Weight | 635117188 |
| Optimization Technique | LBFGS |
| Number of Neural Nets | 1 |
| Objective Value | 0.2194992373 |
| Misclassification Rate for Validation | 0 |
Figure 2 shows the misclassification rate for the training sample.
Figure 2: Score Information for Training Data
| Score Information for Training | |
|---|---|
| Number of Observations Read | 93 |
| Number of Observations Used | 93 |
| Misclassification Rate | 0.0215 |
Figure 3 shows the misclassification rate for the validation sample.
Figure 3: Score Information for Validation Data
| Score Information for Validation | |
|---|---|
| Number of Observations Read | 57 |
| Number of Observations Used | 57 |
| Misclassification Rate | 0 |