Create a resamples object
Now that you have fit two models to the churn dataset, it's time to compare their out-of-sample predictions and choose which one is the best model for your dataset.
You can compare models in caret
using the resamples()
function, provided they have the same training data and use the same trainControl
object with preset cross-validation folds. resamples()
takes as input a list of models and can be used to compare dozens of models at once (though in this case you are only comparing two models).
This exercise is part of the course
Machine Learning with caret in R
Exercise instructions
model_glmnet
and model_rf
are loaded in your workspace.
- Create a
list()
containing theglmnet
model asitem1
and theranger
model asitem2
. - Pass this list to the
resamples()
function and save the resulting object asresamples
. - Summarize the results by calling
summary()
onresamples
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create model_list
model_list <- list(item1 = ___, item2 = ___)
# Pass model_list to resamples(): resamples
# Summarize the results