Cross-validation

Machine Learning with caret in R

Zach Mayer

Data Scientist at DataRobot and co-author of caret

Cross-validation

Machine Learning with caret in R

Cross-validation

Machine Learning with caret in R

Cross-validation

Machine Learning with caret in R

Cross-validation

Machine Learning with caret in R

Fit final model on full dataset

Machine Learning with caret in R

Fit final model on full dataset

Machine Learning with caret in R

Cross-validation

# Set seed for reproducibility
set.seed(42)
# Fit linear regression model
model <- train(
  mpg ~ hp, mtcars, 
  method = "lm",
  trControl = trainControl(
    method = "cv", 
    number = 10,
    verboseIter = TRUE
  )
)
+ Fold01: intercept=TRUE 
- Fold01: intercept=TRUE 
...
- Fold10: intercept=TRUE 
Aggregating results
Fitting final model on full training set
Machine Learning with caret in R

Let's practice!

Machine Learning with caret in R

Preparing Video For Download...