
Last chance! 50% off unlimited learning
Sale ends in
Make predictions from a caretStack. This function passes the data to each function in turn to make a matrix of predictions, and then multiplies that matrix by the vector of weights to get a single, combined vector of predictions.
# S3 method for caretStack
predict(
object,
newdata = NULL,
se = FALSE,
level = 0.95,
return_weights = FALSE,
na.action = na.omit,
...
)
a caretStack
to make predictions from.
a new dataframe to make predictions on
logical, should prediction errors be produced? Default is false.
tolerance/confidence level
a logical indicating whether prediction weights for each model should be returned
the method for handling missing data passed to predict.train
.
arguments to pass to predict.train
.
Prediction weights are defined as variable importance in the stacked caret model. This is not available for all cases such as where the library model predictions are transformed before being passed to the stacking model.
if (FALSE) {
library("rpart")
models <- caretList(
x=iris[1:100,1:2],
y=iris[1:100,3],
trControl=trainControl(method="cv"),
methodList=c("rpart", "glm")
)
meta_model <- caretStack(models, method="lm")
RMSE(predict(meta_model, iris[101:150,1:2]), iris[101:150,3])
}
Run the code above in your browser using DataLab