myformula <- close ~ High+Low+Open
nn_close <- neuralnet(myformula,data=train_,hidden=c(5,3),linear.output=T)
nn_close$net.result[[1]]
Hi, given the above lines. I have constructed a neural network model which I will use to attempt to predict the close price. Please could someone explain to me what the nn_close$net.result[[1]]
line does? I have checked the CRAN documentation but this is still not clear to me.
The results from
compute()$net.result
only contain one level and this gives the probability of each sample to be a given species (in this example). In other words, the sum of the rows is (roughly) equal to 1. In the following example, I have used this information to predict the species in the validation subset of the data, and these are compared with their true values usingtable
:In my case, all setosa samples were correctly predicted. There were 2 and 4 false predictions for versicolor and virginica, respectively. Generally, the prediction was correct for 92% of the validation samples (69/75 * 100).
You will understand this better with an example (I modified it a bit but I got it from here):
Now take a look at the results:
I used
compute
to make a prediction on the training set using the neural network model.As you can see
inet$net.result[[1]]
andpredict$net.result
are the same. So,inet$net.result[[1]]
is just a prediction on the data set that you used to train the model (it is the same as fitted.values of thelm
model).As per @sebastianmm 's really useful comment there is a reason why
net.result
is a list. Basically,neuralnet
has a parameterrep
, which makes it possible to train multiple models in one call. Whenrep
is larger than 1,net.result
will be larger than 1 (as will other components (weights
,result.matrix
,start.weights
)).