The caret (Classification And REgression Training) package provides a consistent interface to over 200 predictive modeling algorithms in R. It wraps the training, tuning, and evaluation steps into a single workflow centered on the train() function.

What’s covered#

  • Specifying the Model – formula, x/y, and recipe interfaces to train()
  • Preprocessing – preProc options for centering, scaling, imputation, and filtering
  • Adding Options – trainControl() for resampling and other settings
  • Resampling Options – k-fold CV, repeated CV, bootstrap, LGOCV, LOO, time-slice
  • Performance Metrics – summaryFunction with defaultSummary, twoClassSummary, prSummary
  • Grid Search – tuneGrid with expand.grid() for explicit tuning parameter values
  • Random Search – tuneLength with search = "random" in trainControl()
  • Subsampling – sampling option for class imbalance (down, up, SMOTE, ROSE)
  • Parallel Processing – doMC (macOS/Linux) and doParallel (Windows) via foreach