predict.caretStack: Make predictions from a caretStack

Description Usage Arguments Details Examples

View source: R/caretStack.R

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

1
2
3
## S3 method for class 'caretStack'
predict(object, newdata = NULL, se = FALSE,
  level = 0.95, return_weights = FALSE, na.action = na.omit, ...)

Arguments

object

a caretStack to make predictions from.

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 predict.train.

...

arguments to pass to predict.train.

Details

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

zachmayer/caretEnsemble documentation built on Nov. 7, 2017, 5:01 a.m.