Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

caretList

Create a list of several train models from the caret package Build a list of train objects suitable for ensembling using the caretEnsemble function.


Description

Create a list of several train models from the caret package Build a list of train objects suitable for ensembling using the caretEnsemble function.

Usage

caretList(..., trControl = NULL, methodList = NULL, tuneList = NULL,
  continue_on_fail = FALSE)

Arguments

...

arguments to pass to train. These arguments will determine which train method gets dispatched.

trControl

a trainControl object. We are going to intercept this object check that it has the "index" slot defined, and define the indexes if they are not.

methodList

optional, a character vector of caret models to ensemble. One of methodList or tuneList must be specified.

tuneList

optional, a NAMED list of caretModelSpec objects. This much more flexible than methodList and allows the specificaiton of model-specific parameters (e.g. passing trace=FALSE to nnet)

continue_on_fail,

logical, should a valid caretList be returned that excludes models that fail, default is FALSE

Value

A list of train objects. If the model fails to build, it is dropped from the list.

Examples

## Not run: 
myControl <- trainControl(method="cv", number=5)
caretList(
  Sepal.Length ~ Sepal.Width,
  head(iris, 50),
  methodList=c("glm", "lm"),
  trControl=myControl
  )
caretList(
  Sepal.Length ~ Sepal.Width,
  head(iris, 50), methodList=c("lm"),
  tuneList=list(
    nnet=caretModelSpec(method="nnet", trace=FALSE, tuneLength=1)
 ),
  trControl=myControl
  )
  
## End(Not run)

caretEnsemble

Ensembles of Caret Models

v2.0.1
MIT + file LICENSE
Authors
Zachary A. Deane-Mayer [aut, cre], Jared E. Knowles [aut]
Initial release
2019-12-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.