Skip to contents

Generalized random forest for regression. Calls grf::regression_forest() from grf.

Custom mlr3 parameters

  • sample.weights is not exposed as a hyperparameter. Observation weights are taken from the task instead, see the weights property.

  • estimate.variance is not exposed as a hyperparameter. It is enabled automatically when the predict_type is "se", which requires ci.group.size to be at least 2.

Dictionary

This Learner can be instantiated via lrn():

lrn("regr.grf")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”, “se”

  • Feature Types: “integer”, “numeric”

  • Required Packages: mlr3, mlr3extralearners, grf

Parameters

IdTypeDefaultLevelsRange
num.treesinteger2000\([1, \infty)\)
clustersuntypedNULL-
equalize.cluster.weightslogicalFALSETRUE, FALSE-
sample.fractionnumeric0.5\([0, 1]\)
mtryinteger-\([1, \infty)\)
min.node.sizeinteger5\([1, \infty)\)
honestylogicalTRUETRUE, FALSE-
honesty.fractionnumeric0.5\([0, 1]\)
honesty.prune.leaveslogicalTRUETRUE, FALSE-
alphanumeric0.05\([0, 0.25]\)
imbalance.penaltynumeric0\([0, \infty)\)
ci.group.sizeinteger2\([1, \infty)\)
tune.parametersuntyped"none"-
tune.num.treesinteger50\([1, \infty)\)
tune.num.repsinteger100\([1, \infty)\)
tune.num.drawsinteger1000\([1, \infty)\)
compute.oob.predictionslogicalTRUETRUE, FALSE-
seedinteger-\((-\infty, \infty)\)
linear.correction.variablesuntypedNULL-
ll.lambdanumericNULL\([0, \infty)\)
ll.weight.penaltylogicalFALSETRUE, FALSE-
num.threadsinteger-\([1, \infty)\)

References

Athey, Susan, Tibshirani, Julie, Wager, Stefan (2019). “Generalized random forests.” The Annals of Statistics, 47(2), 1148–1178. doi:10.1214/18-AOS1709 .

See also

Author

jesuisantoine

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrGRF

Methods

Inherited methods


LearnerRegrGRF$new()

Creates a new instance of this R6 class.

Usage


LearnerRegrGRF$clone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrGRF$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("regr.grf")
print(learner)
#> 
#> ── <LearnerRegrGRF> (regr.grf): Generalized Random Forest ──────────────────────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3extralearners, and grf
#> • Predict Types: [response] and se
#> • Feature Types: integer and numeric
#> • Encapsulation: none (fallback: -)
#> • Properties: missings and weights
#> • Other settings: use_weights = 'use', predict_raw = 'FALSE'

# Define a Task
task = tsk("mtcars")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

print(learner$model)
#> GRF forest object of type regression_forest 
#> Number of trees: 2000 
#> Number of training samples: 21 
#> Variable importance: 
#>  1  2  3  4  5  6  7  8  9 10 
#>  0  0  0  0  0  0  0  0  0  0 


# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
#> regr.mse 
#> 67.41058