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:
average
Averaging of base learner predictions without weights.
stack.nocv
Fits the super learner, where in-sample predictions of
the base learners are used.
stack.cv
Fits the super learner, where the base learner predictions
are computed by cross-validated predictions (the resampling strategy can be
set via the resampling
argument).
hill.climb
Select a subset of base learner predictions by hill
climbing algorithm.
compress
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 | (Learner | character(1)) |
predict.type | (
|
method | ( |
use.feat | ( |
resampling | (ResampleDesc) |
parset | the parameters for
the parameters for
|
# 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