caretList: Create a list of several train models from the caret package

View source: R/caretList.R

caretListR Documentation

Create a list of several train models from the caret package

Description

Build a list of train objects suitable for ensembling using the caretStack function.

Usage

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

Arguments

...

arguments to pass to train. Don't use the formula interface, its slower and buggier compared to the X, y interface. Use a data.table for X. Particularly if you have a large dataset and/or many models, using a data.table will avoid unnecessary copies of your data and can save a lot of time and RAM. These arguments will determine which train method gets dispatched.

trControl

a trainControl object. If NULL, will use defaultControl.

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 specification of model-specific parameters (e.g. passing trace=FALSE to nnet)

metric

a string, the metric to optimize for. If NULL, we will choose a good one.

continue_on_fail

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

trim

logical should the train models be trimmed to save memory and speed up stacking

Value

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

Examples

caretList(
  Sepal.Length ~ Sepal.Width,
  head(iris, 50),
  methodList = c("glm", "lm"),
  tuneList = list(
    nnet = caretModelSpec(method = "nnet", trace = FALSE, tuneLength = 1)
  )
)

caretEnsemble documentation built on Sept. 13, 2024, 1:11 a.m.