Solved – How to retrieve model-specific information when using the caret package

caretr

CARET is a convenient tool that wraps dozens of modelling methods. CARET allows the user to access performance statistics such as RMSE, confusion matrices, etc. in a generic way without having to recall the usage of various modeling methods.

However, some models have unique reporting outcomes. For example, with a boosted tree model one can compare the in-sample vs. out-sample error-rate as a function of the number of trees to test for overfitting. Naturally this report would not make sense with other methods that do not use trees.

Is there a way I can use CARET to access these model-specific reports (maybe by accessing the modeling object generated directly)?

Best Answer

The train function in caret returns an S3 list object. On of the items in this list is called finalModel. This item is just the fitted object in it's native form. So if you trained a gbm using train and stored it in an object called my.fit, then summary(my.fit$finalModel) would use the summary.gbm method from the gbm package and show you the relative variable importance.