Skip to contents

Setup hyperparameters for a SuperLearner: the cross-validated stacked ensemble of van der Laan, Polley & Hubbard (2007).

Usage

setup_SuperLearner(
  base_learners = list(setup_GLM(), setup_GLMNET(), setup_Ranger()),
  meta_learner = setup_NNLS(),
  inner_resampling_config = setup_Resampler(n_resamples = 10L, type = "KFold"),
  discrete = FALSE,
  expand_search_spaces = TRUE,
  ifw = FALSE
)

Arguments

base_learners

List of Hyperparameters objects: The library. Names label the level-one predictions and the reported weights; unnamed entries are named after their algorithm.

meta_learner

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.

inner_resampling_config

ResamplerConfig object: Cross-validation scheme used to build the level-one predictions.

discrete

(Tunable) Logical: If TRUE, keep the single lowest-risk library entry rather than the weighted combination (the discrete SuperLearner).

expand_search_spaces

Logical: If TRUE, expand a base learner's search space into one library entry per combination.

ifw

(Tunable) Logical: If TRUE, use Inverse Frequency Weighting in classification.

Value

SuperLearnerHyperparameters object.

Details

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.

Author

EDG

Examples

superlearner_hyperparams <- setup_SuperLearner(
  base_learners = list(setup_GLM(), setup_CART())
)
superlearner_hyperparams
#> <SuperLearnerHyperparameters>
#>         hyperparameters: 
#>                                    base_learners: <chr> GLM, CART
#>                                     meta_learner: <chr> NNLS
#>                          inner_resampling_config: <chr> 10 independent folds
#>                             expand_search_spaces: <lgc> TRUE
#>                                              ifw: <lgc> FALSE
#>                                         discrete: <lgc> FALSE
#> tunable_hyperparameters: <chr> ifw, discrete
#>   fixed_hyperparameters: <chr> base_learners, meta_learner, inner_resampling_config, expand_search_spaces
#>                   tuned: <int> -1
#>               resampled: <int> 0
#>               n_workers: <int> 1