LoslegenKostenlos loslegen

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).

Diese Übung ist Teil des Kurses

Machine Learning with caret in R

Kurs anzeigen

Anleitung zur Übung

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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Create model_list
model_list <- list(item1 = ___, item2 = ___)

# Pass model_list to resamples(): resamples


# Summarize the results
Code bearbeiten und ausführen