mlr_learners_regr.ranger {mlr3learners}R Documentation

Ranger Regression Learner

Description

Random regression forest. Calls ranger::ranger() from package ranger.

Dictionary

This mlr3::Learner can be instantiated via the dictionary mlr3::mlr_learners or with the associated sugar function mlr3::lrn():

mlr_learners$get("regr.ranger")
lrn("regr.ranger")

Meta Information

Parameters

Id Type Default Levels Range
alpha numeric 0.5 (-\infty, \infty)
always.split.variables untyped - -
holdout logical FALSE TRUE, FALSE -
importance character - none, impurity, impurity_corrected, permutation -
keep.inbag logical FALSE TRUE, FALSE -
max.depth integer NULL [0, \infty)
min.bucket integer 1 [1, \infty)
min.node.size integer 5 [1, \infty)
minprop numeric 0.1 (-\infty, \infty)
mtry integer - [1, \infty)
mtry.ratio numeric - [0, 1]
node.stats logical FALSE TRUE, FALSE -
num.random.splits integer 1 [1, \infty)
num.threads integer 1 [1, \infty)
num.trees integer 500 [1, \infty)
oob.error logical TRUE TRUE, FALSE -
quantreg logical FALSE TRUE, FALSE -
regularization.factor untyped 1 -
regularization.usedepth logical FALSE TRUE, FALSE -
replace logical TRUE TRUE, FALSE -
respect.unordered.factors character ignore ignore, order, partition -
sample.fraction numeric - [0, 1]
save.memory logical FALSE TRUE, FALSE -
scale.permutation.importance logical FALSE TRUE, FALSE -
se.method character infjack jack, infjack -
seed integer NULL (-\infty, \infty)
split.select.weights untyped NULL -
splitrule character variance variance, extratrees, maxstat -
verbose logical TRUE TRUE, FALSE -
write.forest logical TRUE TRUE, FALSE -

Custom mlr3 parameters

Initial parameter values

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrRanger

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
LearnerRegrRanger$new()

Method importance()

The importance scores are extracted from the model slot variable.importance. Parameter importance.mode must be set to "impurity", "impurity_corrected", or "permutation"

Usage
LearnerRegrRanger$importance()
Returns

Named numeric().


Method oob_error()

The out-of-bag error, extracted from model slot prediction.error.

Usage
LearnerRegrRanger$oob_error()
Returns

numeric(1).


Method clone()

The objects of this class are cloneable with this method.

Usage
LearnerRegrRanger$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

Wright, N. M, Ziegler, Andreas (2017). “ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R.” Journal of Statistical Software, 77(1), 1–17. doi:10.18637/jss.v077.i01.

Breiman, Leo (2001). “Random Forests.” Machine Learning, 45(1), 5–32. ISSN 1573-0565, doi:10.1023/A:1010933404324.

See Also

Other Learner: mlr_learners_classif.cv_glmnet, mlr_learners_classif.glmnet, mlr_learners_classif.kknn, mlr_learners_classif.lda, mlr_learners_classif.log_reg, mlr_learners_classif.multinom, mlr_learners_classif.naive_bayes, mlr_learners_classif.nnet, mlr_learners_classif.qda, mlr_learners_classif.ranger, mlr_learners_classif.svm, mlr_learners_classif.xgboost, mlr_learners_regr.cv_glmnet, mlr_learners_regr.glmnet, mlr_learners_regr.kknn, mlr_learners_regr.km, mlr_learners_regr.lm, mlr_learners_regr.nnet, mlr_learners_regr.svm, mlr_learners_regr.xgboost

Examples

if (requireNamespace("ranger", quietly = TRUE)) {
# Define the Learner and set parameter values
learner = lrn("regr.ranger")
print(learner)

# 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 the model
print(learner$model)

# importance method
if("importance" %in% learner$properties) print(learner$importance)

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

# Score the predictions
predictions$score()
}

[Package mlr3learners version 0.7.0 Index]