mlr_learners_regr.randomForest: Regression Random Forest Learner

mlr_learners_regr.randomForestR Documentation

Regression Random Forest Learner

Description

Random forest for regression. Calls randomForest::randomForest() from randomForest.

Dictionary

This Learner can be instantiated via lrn():

lrn("regr.randomForest")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3extralearners, randomForest

Parameters

Id Type Default Levels Range
ntree integer 500 [1, \infty)
mtry integer - [1, \infty)
replace logical TRUE TRUE, FALSE -
strata untyped - -
sampsize untyped - -
nodesize integer 5 [1, \infty)
maxnodes integer - [1, \infty)
importance character FALSE mse, nudepurity, none -
localImp logical FALSE TRUE, FALSE -
proximity logical FALSE TRUE, FALSE -
oob.prox logical - TRUE, FALSE -
norm.votes logical TRUE TRUE, FALSE -
do.trace logical FALSE TRUE, FALSE -
keep.forest logical TRUE TRUE, FALSE -
keep.inbag logical FALSE TRUE, FALSE -
predict.all logical FALSE TRUE, FALSE -
nodes logical FALSE TRUE, FALSE -

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrRandomForest

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
LearnerRegrRandomForest$new()

Method importance()

The importance scores are extracted from the slot importance. Parameter 'importance' must be set to either "mse" or "nodepurity".

Usage
LearnerRegrRandomForest$importance()
Returns

Named numeric().


Method oob_error()

OOB errors are extracted from the model slot mse.

Usage
LearnerRegrRandomForest$oob_error()
Returns

numeric(1).


Method clone()

The objects of this class are cloneable with this method.

Usage
LearnerRegrRandomForest$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

pat-s

References

Breiman, Leo (2001). “Random Forests.” Machine Learning, 45(1), 5–32. ISSN 1573-0565, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1023/A:1010933404324")}.

See Also

Examples


# Define the Learner
learner = mlr3::lrn("regr.randomForest")
print(learner)

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

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

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

print(learner$model)
print(learner$importance)

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

# Score the predictions
predictions$score()


mlr-org/mlr3extralearners documentation built on Sept. 16, 2024, 3:11 a.m.