9  Supervised learning

train() fits a supervised model from tabular data and typed configurations. The same interface supports a single fit, hyperparameter tuning, outer resampling, and nested selection and assessment.

9.1 Inputs and outputs

For direct tabular input, the last column is the outcome. Use set_outcome() to place a named column last. Predictors are numeric or factor columns. Binary classification uses the second outcome factor level as the positive class; set_positive_class() sets that convention explicitly.

Outcome Single fit Outer resampling
Numeric Regression RegressionRes
Factor Classification ClassificationRes

Inputs may be data.frame, data.table, or tibble objects. Prediction input contains the training predictors in training order, without the outcome.

9.2 Configuration components

Argument Purpose
hyperparameters Learner and its settings, selected by a setup_*() constructor.
preprocessor_config Transformations learned on training data.
decomposition_config A decomposition that can be applied to new cases.
tuner_config Search strategy, selection metric, and inner resampling.
outer_resampling_config Training/assessment splits for the full procedure.
execution_config Backend, workers, device, seed, and error policy.
dat_test Held-out data for performance assessment.
weights One finite, nonnegative weight per training case, with positive mean.

tuner_config specifies how hyperparameters are selected. Pass a configuration from setup_GridSearch() to set the search strategy, selection metric, optimization direction, metric aggregation, and internal resampling scheme. See hyperparameter tuning for the controls and examples.

mod <- train(
  set_outcome(mtcars, "mpg"),
  hyperparameters = setup_GLM(),
  execution_config = setup_SerialExecution(seed = 2026L)
)
2026-10-08 03:42:35 Checking data is ready for training... ✔ [check_supervised]
2026-10-08 03:42:35 ▶ [train]
2026-10-08 03:42:36 Training set: 32 cases x 10 features. [summarize_supervised]
2026-10-08 03:42:36 // CPU | serial | 1 worker: algorithm 1 thread, tuning 1, outer resampling 1 [msg_resources]
2026-10-08 03:42:36 Shared memory (auto): not sharing training data (7.2 kB) -- this run transfers nothing to workers. [report_shared_memory]
2026-10-08 03:42:36 Training GLM Regression... [train]
2026-10-08 03:42:36 Checking data is ready for training... ✔ [check_supervised]

<Regression>
GLM (GLM (generalized linear model))

  <Training Regression Metrics>
   MAE: 1.72
   MSE: 4.61
  RMSE: 2.15
    R²: 0.87

2026-10-08 03:42:36 Done in 0.71 seconds. [train]
describe(mod)
GLM (generalized linear model) was used for regression. R-squared was 0.87 on the training set. 

This fit uses every row for training; its training metrics describe fit to those rows. Regression and classification examples include held-out assessment.

9.3 Learner families

available_supervised()
                     BART: Bayesian Additive Regression Trees (stochtree)
                     CART: CART decision tree (rpart)
  ConditionalSuperLearner: Conditional SuperLearner: an oracle routes each case to one of a library of experts
                      GAM: GAM (generalized additive model)
                      GLM: GLM (generalized linear model)
                   GLMNET: Elastic net (glmnet)
                  GLMTree: Model-Based Recursive Partitioning: a tree with a GLM in each leaf
                      HAL: Highly Adaptive Lasso (hal9001)
                 Isotonic: Isotonic regression
             MonotonicHAL: Monotonic Highly Adaptive Lasso (hal9001)
                      KNN: k-Nearest Neighbors (kknn)
                LightCART: Single LightGBM tree (CART mode)
                 LightGBM: LightGBM gradient boosting
                  LightRF: LightGBM random forest
             LightRuleFit: LightRuleFit (LightGBM rules + GLMNET)
                    LINAD: Linear Additive Tree
              LINADForest: Bagged ensemble of Linear Additive Trees
                     MARS: Multivariate Adaptive Regression Splines (earth)
                      MLP: Multilayer perceptron (torch)
         ModalityStacking: ModalityStacking: stacked ensemble with one learner per feature group
                     NNLS: Non-negative least squares (nnls)
                   Ranger: Ranger random forest
             SuperLearner: SuperLearner: cross-validated stacked ensemble
                LinearSVM: SVM with linear kernel (e1071)
                RadialSVM: SVM with radial kernel (e1071)
                     SPLS: Sparse Partial Least Squares
                   TabNet: TabNet neural network

The interface includes generalized linear and additive models, regularized regression, nearest neighbors, support vector machines, trees and forests, gradient boosting, neural networks, and stacked ensembles. Each setup function documents its backend, task support, constraints, and tunable properties. train() uses Ranger when hyperparameters are omitted.

tune_over() marks candidate values for hyperparameter selection. Bare vectors retain their declared meaning, such as a network architecture.

9.4 Fitted state

S7 properties are accessed with @; ordinary list elements use [[. describe() summarizes a fit, predict() applies it to new data, and review() assesses its recorded performance. The model retains configuration and execution information for reporting and export.

© 2026 E.D. Gennatas