Comparing models

Machine Learning with caret in R

Zach Mayer

Data Scientist at DataRobot and co-author of caret

Comparing models

  • Make sure they were fit on the same data!
  • Selection criteria
    • Highest average AUC
    • Lowest standard deviation in AUC
  • The resamples() function is your friend
Machine Learning with caret in R

Example: resamples() on churn data

# Make a list
model_list <- list(
  glmnet = model_glmnet,
  rf = model_rf
)
# Collect resamples from the CV folds
resamps <- resamples(model_list)
resamps
Call:
resamples.default(x = model_list)

Models: glmnet, rf 
Number of resamples: 5 
Performance metrics: ROC, Sens, Spec 
Time estimates for: everything, final model fit 
Machine Learning with caret in R

Summarize the results

# Summarize the results
summary(resamps)
Call:
summary.resamples(object = resamps)

Models: glmnet, rf 
Number of resamples: 5 

ROC 
         Min. 1st Qu. Median   Mean 3rd Qu.   Max. NA's
glmnet 0.7526  0.7624 0.7719 0.7686  0.7722 0.7840    0
rf     0.8984  0.9028 0.9077 0.9061  0.9093 0.9125    0
Machine Learning with caret in R

Let’s practice!

Machine Learning with caret in R

Preparing Video For Download...