I'd like to ask how can I convert the final model that I get from a grid search with caret's 'train' function into an object of the class that is created with the glmnet function, assuming that I specified method='glmnet'.
Asked
Active
Viewed 785 times
1 Answers
2
I'll answer myself (found it looking with different terms): the final model is saved in the train object as attribute 'finalModel', so if the train object is called 'fit', it can be accessed by fit$finalModel

anymous_asker
- 113
- 1
- 11
-
4Be very careful. The object in `finalModel` doesn't know anything about what `train` did. If you used any pre-process or other features of `train`, you will get incorrect predictions using the `finalModel` object. – topepo Aug 22 '15 at 16:32