Get startedGet started for free

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

View Course

Exercise instructions

model_glmnet and model_rf are loaded in your workspace.

  • Create a list() containing the glmnet model as item1 and the ranger model as item2.
  • Pass this list to the resamples() function and save the resulting object as resamples.
  • Summarize the results by calling summary() on resamples.

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
Edit and Run Code