Setup hyperparameters for a SuperLearner: the cross-validated stacked ensemble of van der Laan, Polley & Hubbard (2007).
setup_SuperLearner(
base_learners = list(setup_GLM(), setup_GLMNET(), setup_Ranger()),
meta_learner = setup_NNLS(),
inner_resampling_config = setup_KFold(n_resamples = 10L),
discrete = FALSE,
expand_search_spaces = TRUE,
ifw = FALSE
)SuperLearnerHyperparameters object.
List of Hyperparameters objects: The library. Names
label the level-one predictions and the reported weights; unnamed entries are
named after their algorithm.
Hyperparameters object: Learner fitted on the base
learners' cross-validated predictions. The default is non-negative least
squares normalized to sum to 1, i.e. a convex combination.
ResamplerConfig object: Cross-validation
scheme used to build the level-one predictions.
(Tunable) Logical: If TRUE, keep the single lowest-risk library entry rather than the weighted combination (the discrete SuperLearner).
Logical: If TRUE, expand a base learner's search space into one library entry per combination.
(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification.
EDG
Each base learner is fitted on every training fold of inner_resampling_config
and predicts that fold's held-out cases, producing one cross-validated
prediction per case per learner. The meta learner is fitted on those
predictions against the outcome, and its coefficients are the ensemble
weights. Every base learner is then refitted on the whole training set, so a
prediction is the meta learner applied to the base learners' predictions.
Search spaces become library entries. A base learner holding more than one
value for a tunable hyperparameter is expanded into one library entry per
combination, and the ensemble weights choose between them -- the ensemble's
own cross-validation is the model selection, so no inner tuning is needed.
Set expand_search_spaces = FALSE to tune each such learner by inner
resampling within every fold instead, which is far more expensive. A learner
that tunes itself (GLMNET choosing lambda by cv.glmnet) is unaffected
either way.
The cross-validated predictions and the resampler are kept on the fitted model, which is what a cross-fitting estimator needs from it.
Supports regression and binary classification.
superlearner_hyperparams <- setup_SuperLearner(
base_learners = list(setup_GLM(), setup_CART())
)
superlearner_hyperparams
Run the code above in your browser using DataLab