Skip to contents

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

Dictionary

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

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

Meta Information

  • Task type: “regr”

  • Predict Types: “response”, “se”

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

  • Required Packages: mlr3, mlr3learners, ranger

Parameters

IdTypeDefaultRangeLevels
alphanumeric0.5\((-\infty, \infty)\)-
always.split.variableslist---
holdoutlogicalFALSE-TRUE, FALSE
importancecharacter--none, impurity, impurity_corrected, permutation
keep.inbaglogicalFALSE-TRUE, FALSE
max.depthintegerNULL\([0, \infty)\)-
min.node.sizeinteger5\([1, \infty)\)-
min.propnumeric0.1\((-\infty, \infty)\)-
minpropnumeric0.1\((-\infty, \infty)\)-
mtryinteger-\([1, \infty)\)-
mtry.rationumeric-\([0, 1]\)-
num.random.splitsinteger1\([1, \infty)\)-
num.threadsinteger1\([1, \infty)\)-
num.treesinteger500\([1, \infty)\)-
oob.errorlogicalTRUE-TRUE, FALSE
quantreglogicalFALSE-TRUE, FALSE
regularization.factorlist1--
regularization.usedepthlogicalFALSE-TRUE, FALSE
replacelogicalTRUE-TRUE, FALSE
respect.unordered.factorscharacterignore-ignore, order, partition
sample.fractionnumeric-\([0, 1]\)-
save.memorylogicalFALSE-TRUE, FALSE
scale.permutation.importancelogicalFALSE-TRUE, FALSE
se.methodcharacterinfjack-jack, infjack
seedintegerNULL\((-\infty, \infty)\)-
split.select.weightslistNULL--
splitrulecharactervariance-variance, extratrees, maxstat
verboselogicalTRUE-TRUE, FALSE
write.forestlogicalTRUE-TRUE, FALSE

Custom mlr3 defaults

  • num.threads:

    • Actual default: NULL, triggering auto-detection of the number of CPUs.

    • Adjusted value: 1.

    • Reason for change: Conflicting with parallelization via future.

  • mtry:

    • This hyperparameter can alternatively be set via our hyperparameter mtry.ratio as mtry = max(ceiling(mtry.ratio * n_features), 1). Note that mtry and mtry.ratio are mutually exclusive.

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.svm, mlr_learners_regr.xgboost, mlr_learners_surv.cv_glmnet, mlr_learners_surv.glmnet, mlr_learners_surv.ranger, mlr_learners_surv.xgboost

Super classes

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

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


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.

Examples

if (requireNamespace("ranger", quietly = TRUE)) {
  learner = mlr3::lrn("regr.ranger")
  print(learner)

  # available parameters:
learner$param_set$ids()
}
#> <LearnerRegrRanger:regr.ranger>
#> * Model: -
#> * Parameters: num.threads=1
#> * Packages: mlr3, mlr3learners, ranger
#> * Predict Type: response
#> * Feature types: logical, integer, numeric, character, factor, ordered
#> * Properties: hotstart_backward, importance, oob_error, weights
#>  [1] "alpha"                        "always.split.variables"      
#>  [3] "holdout"                      "importance"                  
#>  [5] "keep.inbag"                   "max.depth"                   
#>  [7] "min.node.size"                "min.prop"                    
#>  [9] "minprop"                      "mtry"                        
#> [11] "mtry.ratio"                   "num.random.splits"           
#> [13] "num.threads"                  "num.trees"                   
#> [15] "oob.error"                    "quantreg"                    
#> [17] "regularization.factor"        "regularization.usedepth"     
#> [19] "replace"                      "respect.unordered.factors"   
#> [21] "sample.fraction"              "save.memory"                 
#> [23] "scale.permutation.importance" "se.method"                   
#> [25] "seed"                         "split.select.weights"        
#> [27] "splitrule"                    "verbose"                     
#> [29] "write.forest"