the model created by nnet package in R return "strange" results

260 views Asked by At

I need to do some work by neural network in R, and have checked with both the nnet package and neuralnet package. To understand the functions offered by the nnet package, I wrote the following code based on the iris dataset:

 iris=read.csv("iris.csv",header=F)
 iris <- iris[sample(1:nrow(iris)),]
 train <- iris[1:100,]
 test <- iris[101:150,]
 model_nnet <- nnet(iris[1:100,5] ~ ., data=train, size=10)
 result<-predict(model_nnet, test)

However, no matter how I changed the code or the dataset, I always get the results similar to the following part:

   row.names    V1
 1  138 1
 2  54  1
 3  150 1
 4  108 1
 5  119 1
 6  96  1
 7  104 1
 8  37  1
 9  16  1
10  92  1
11  60  1
12  6   1
 .....

The V1 features should be the mixture of 1,2,3 (this is the target variable), instead of only 1. Does anyone have any idea on my code?

0

There are 0 answers