regularized <- setup_GLMNET(alpha = tune_over(0, 0.5, 1))
splines <- setup_MARS()
sparse_components <- setup_SPLS(k = 2L, eta = 0.5)14 Learner families
Learner configurations specify an algorithm and its settings. The shared training interface supplies preprocessing, resampling, assessment, and execution controls. Task support and input restrictions are defined by the selected learner.
14.1 Regression, regularization, and local methods
| Constructor | Model or estimator |
|---|---|
setup_GLM() |
Generalized linear model. |
setup_GAM() |
Generalized additive model. |
setup_GLMNET() |
Elastic-net regularization through GLMNET. |
setup_MARS() |
Multivariate adaptive regression splines. |
setup_SPLS() |
Sparse partial least squares. |
setup_KNN() |
Weighted nearest neighbors. |
setup_LinearSVM(), setup_RadialSVM() |
Linear and radial-kernel support vector machines. |
setup_HAL() |
Highly adaptive lasso. |
setup_BART() |
Bayesian additive regression trees through stochtree. |
These configurations expose different statistical assumptions and complexity controls. A common interface supports a common assessment design; it does not make their coefficients, importance measures, or uncertainty estimates interchangeable.
For GLMNET, alpha controls the ridge/lasso mixture and lambda controls the penalty path. Its documented lambda-selection policy forms part of the fit. HAL constructs a basis whose size depends on the data and configuration; max_basis bounds that expansion. BART retains posterior information, and se() reports the posterior standard deviation of the mean function.
14.2 Neural networks
setup_MLP() configures a multilayer perceptron through torch. Hidden layers can be specified explicitly or generated from a shape configuration. Categorical inputs use learned embeddings or one-hot encoding; numeric inputs are centered and scaled by the learner.
mlp_config <- setup_MLP(
hidden_units = c(16L, 8L),
max_epochs = 20L,
patience = 5L
)
tabnet_config <- setup_TabNet(epochs = 20L)setup_TabNet() configures an attention-based tabular neural network. skip_importance controls importance computation; importance_sample_size applies when importance is computed.
The following fit requires a working torch runtime and is shown without execution in the book build:
mod <- train(
iris[c(1:40, 51:90, 101:140), ],
dat_test = iris[c(41:50, 91:100, 141:150), ],
hyperparameters = mlp_config,
execution_config = setup_SerialExecution(
n_workers_algorithm = 1L, device = "cpu", seed = 2026L
)
)max_epochs sets the training budget. plot_learning() and get_learning_curve() expose training progress where recorded. The execution configuration selects the device and algorithm threads for neural-network fitting and prediction.
14.3 Trees and ensembles
The following chapters cover forests, boosting, linear additive trees, rule models, and stacked ensembles. setup_GLMTree() additionally fits model-based recursive partitioning through partykit, with separate sets of regressors and partitioning variables.