Skip to content

rand_forest() defines a model that creates a large number of decision trees, each independent of the others. The final prediction uses all predictions from the individual trees and combines them. This function can fit classification, regression, and censored regression models.

There are different ways to fit this model, and the method of estimation is chosen by setting the model engine. The engine-specific pages for this model are listed below.

¹ The default engine. ² Requires a parsnip extension package for censored regression, classification, and regression.

More information on how parsnip is used for modeling is at


  mode = "unknown",
  engine = "ranger",
  mtry = NULL,
  trees = NULL,
  min_n = NULL



A single character string for the prediction outcome mode. Possible values for this model are "unknown", "regression", or "classification".


A single character string specifying what computational engine to use for fitting.


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


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


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


This function only defines what type of model is being fit. Once an engine is specified, the method to fit the model is also defined. See set_engine() for more on setting the engine, including how to set engine arguments.

The model is not trained or fit until the fit() function is used with the data.


#> # A tibble: 6 × 2
#>   engine       mode          
#>   <chr>        <chr>         
#> 1 ranger       classification
#> 2 ranger       regression    
#> 3 randomForest classification
#> 4 randomForest regression    
#> 5 spark        classification
#> 6 spark        regression    

rand_forest(mode = "classification", trees = 2000)
#> Random Forest Model Specification (classification)
#> Main Arguments:
#>   trees = 2000
#> Computational engine: ranger