
average
stack.nocv
stack.cv
resampling
argument).hill.climb
compress
makeStackedLearner(base.learners, super.learner = NULL, predict.type = NULL,
method = "stack.nocv", use.feat = FALSE, resampling = NULL,
parset = list())
Learner
]
A list of learners created with makeLearner
.Learner | character(1)
]
The super learner that makes the final prediction based on the base learners.
If you pass a string, the super learner will be created via makeLearner
.
Not used for method = 'average'
. Default is NULL
.character(1)
]
Sets the type of the final prediction for method = 'average'
.
For other methods, the predict type should be set within super.learner
.
If the type of the base learner prediction, which is set up within base.learners
, is
"prob"
predict.type = 'prob'
will use the average of all
bease learner predictions and predict.type = 'response'
will use
the class with highest probability as final prediction."response"
predict.type = 'prob'
,
the final prediction will be the relative frequency based on the predicted base learner classes
and classification tasks with predict.type = 'response'
will use majority vote of the base
learner predictions to determine the final prediction.
For regression tasks, the final prediction will be the average of the base learner predictions.character(1)
]
“average” for averaging the predictions of the base learners,
“stack.nocv” for building a super learner using the predictions of the base learners,
“stack.cv” for building a super learner using crossvalidated predictions of the base learners.
“hill.climb” for averaging the predictions of the base learners, with the weights learned from
hill climbing algorithm and
“compress” for compressing the model to mimic the predictions of a collection of base learners
while speeding up the predictions and reducing the size of the model.
Default is “stack.nocv”,logical(1)
]
Whether the original features should also be passed to the super learner.
Not used for method = 'average'
.
Default is FALSE
.ResampleDesc
]
Resampling strategy for method = 'stack.cv'
.
Currently only CV is allowed for resampling.
The default NULL
uses 5-fold CV.hill.climb
method, including
replace
init
bagprob
bagtime
metric
pred
and true
,
the smaller the score the better.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)
res = predict(tmp, tsk)
# 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)
res = predict(tmp, tsk)
Run the code above in your browser using DataLab