Learn R Programming

caretEnsemble (version 1.0.0)

predict.caretStack: Make predictions from a caretStack

Description

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.

Usage

## S3 method for class 'caretStack':
predict(object, newdata = NULL, ...)

Arguments

object
a caretStack to make predictions from.
newdata
a new dataframe to make predictions on
...
arguments to pass to predict.train.

Examples

Run this code
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