Reputation: 265
I create nnet models using the caret package and extract the predicted value using the following code:
nnet<-predict(my_model, newdata = my_new_data)
nnet
[1] -0.1468207
I also create the following output whereby I can view the the optimal model parameters as below:
Resampling results across tuning parameters:
size decay RMSE Rsquared RMSE SD Rsquared SD
10 0.001 0.01867841 0.4789708 0.002538599 0.12778927
10 0.100 0.02349088 0.1233067 0.001859455 0.10188046
12 0.001 0.01826047 0.5059824 0.002630588 0.12962511
12 0.100 0.02348553 0.1238252 0.001890646 0.09851303
15 0.001 0.01795350 0.5289120 0.003021449 0.13908835
15 0.100 0.02318972 0.1429446 0.001932714 0.11156927
RMSE was used to select the optimal model using the smallest value.
The final values used for the model were size = 15 and decay = 0.001.
My question is how can I create a variable which just contains the optimal RMSE from the final model? (Instead of having to manually check the output.)
Eg. Something along these lines:
Model_RMSE<-nnet$finalModelRMSE
Model_RMSE
[1] 0.01795350
Thank you
*Update Thanks @SamThomas that's it. I actually wanted just the RMSE from the 'winning/optimum' used model so I just wrapped your suggestion in a min() as below.
>nnet$results["RMSE"]
RMSE
1 0.01867841
2 0.02349088
3 0.01826047
4 0.02348553
5 0.01795350
6 0.02318972
>min(nnet$results["RMSE"])
[1] 0.0179535
Upvotes: 3
Views: 4885
Reputation: 14316
There is already a function to do just this called getTrainPerf
.
Max
Upvotes: 7
Reputation: 6193
Glad the comment helped. If you want the full row from the results, this might be useful.
nnet$results[which.min(nnet$results[, "RMSE"]), ]
Upvotes: 0