predict.caretStack {caretEnsemble} | R Documentation |
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 class 'caretStack' predict(object, newdata = NULL, se = FALSE, level = 0.95, return_weights = FALSE, na.action = na.omit, ...)
object |
a |
newdata |
a new dataframe to make predictions on |
se |
logical, should prediction errors be produced? Default is false. |
level |
tolerance/confidence level |
return_weights |
a logical indicating whether prediction weights for each model should be returned |
na.action |
the method for handling missing data passed to |
... |
arguments to pass to |
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.
## Not run: 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]) ## End(Not run)