Learn R Programming

parsnip (version 0.0.0.9000)

update.rand_forest: Update a Random Forest Specification

Description

If parameters need to be modified, this function can be used in lieu of recreating the object from scratch.

Usage

# S3 method for rand_forest
update(object, mtry = NULL, trees = NULL,
  min_n = NULL, engine_args = list(), fresh = FALSE, ...)

Arguments

object

A random forest model specification.

mtry

An integer for the number of predictors that will be randomly sampled at each split when creating the tree models.

trees

An integer for the number of trees contained in the ensemble.

min_n

An integer for the minimum number of data points in a node that are required for the node to be split further.

engine_args

A named list of arguments to be used by the underlying models (e.g., ranger::ranger, randomForest::randomForest, etc.). These are not evaluated until the model is fit and will be substituted into the model fit expression.

fresh

A logical for whether the arguments should be modifed in-place of or replaced wholesale.

...

Used for method consistency. Any arguments passed to the ellipses will result in an error. Use engine_args instead.

Value

An updated model specification.

Examples

Run this code
# NOT RUN {
model <- rand_forest(mtry = 10, min_n = 3)
model

update(model, mtry = 1)

update(model, mtry = 1, fresh = TRUE)
# }

Run the code above in your browser using DataLab