R/StackedLearner.R
A stacked learner uses predictions of several base learners and fits a super learner using these predictions as features in order to predict the outcome. The following stacking methods are available:
Averaging of base learner predictions without weights.
Fits the super learner, where in-sample predictions of the base learners are used.
Fits the super learner, where the base learner predictions are computed by crossvalidated predictions (the resampling strategy can be set via the `resampling` argument).
Select a subset of base learner predictions by hill climbing algorithm.
Train a neural network to compress the model from a collection of base learners.
makeStackedLearner(base.learners, super.learner = NULL, predict.type = NULL, method = "stack.nocv", use.feat = FALSE, resampling = NULL, parset = list())
| base.learners | [(list of) [Learner]) |
|---|---|
| super.learner | [ |
| predict.type | (`character(1)`)
|
| method | (`character(1)`) |
| use.feat | (`logical(1)`) |
| resampling | ([ResampleDesc]) |
| parset | the parameters for `hill.climb` method, including
the parameters for `compress` method, including
|
# Classification data(iris) tsk = makeClassifTask(data = iris, target = "Species") base = c("classif.rpart", "classif.lda", "classif.svm") lrns = lapply(base, makeLearner) lrns = lapply(lrns, setPredictType, "prob") m = makeStackedLearner(base.learners = lrns, predict.type = "prob", method = "hill.climb") tmp = train(m, tsk)#> Error: Please use column names for `x`#> Error in predict(tmp, tsk): object 'tmp' not found# Regression data(BostonHousing, package = "mlbench") tsk = makeRegrTask(data = BostonHousing, target = "medv") base = c("regr.rpart", "regr.svm") lrns = lapply(base, makeLearner) m = makeStackedLearner(base.learners = lrns, predict.type = "response", method = "compress") tmp = train(m, tsk)#> Error: Please use column names for `x`#> Error in predict(tmp, tsk): object 'tmp' not found