Skip to contents

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

Custom mlr3 parameters

  • 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.

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.

Dictionary

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

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

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

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

  • Required Packages: mlr3, mlr3learners, ranger

Parameters

IdTypeDefaultLevelsRange
alphanumeric0.5\((-\infty, \infty)\)
always.split.variablesuntyped--
class.weightsuntyped-
holdoutlogicalFALSETRUE, FALSE-
importancecharacter-none, impurity, impurity_corrected, permutation-
keep.inbaglogicalFALSETRUE, FALSE-
max.depthintegerNULL\([0, \infty)\)
min.node.sizeintegerNULL\([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.errorlogicalTRUETRUE, FALSE-
regularization.factoruntyped1-
regularization.usedepthlogicalFALSETRUE, FALSE-
replacelogicalTRUETRUE, FALSE-
respect.unordered.factorscharacterignoreignore, order, partition-
sample.fractionnumeric-\([0, 1]\)
save.memorylogicalFALSETRUE, FALSE-
scale.permutation.importancelogicalFALSETRUE, FALSE-
se.methodcharacterinfjackjack, infjack-
seedintegerNULL\((-\infty, \infty)\)
split.select.weightsuntyped-
splitrulecharacterginigini, extratrees, hellinger-
verboselogicalTRUETRUE, FALSE-
write.forestlogicalTRUETRUE, FALSE-

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

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifRanger

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

LearnerClassifRanger$importance()

Returns

Named numeric().


Method oob_error()

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

Usage

LearnerClassifRanger$oob_error()

Returns

numeric(1).


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifRanger$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

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

  # available parameters:
learner$param_set$ids()
}
#> <LearnerClassifRanger:classif.ranger>
#> * Model: -
#> * Parameters: num.threads=1
#> * Packages: mlr3, mlr3learners, ranger
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric, character, factor, ordered
#> * Properties: hotstart_backward, importance, multiclass, oob_error,
#>   twoclass, weights
#>  [1] "alpha"                        "always.split.variables"      
#>  [3] "class.weights"                "holdout"                     
#>  [5] "importance"                   "keep.inbag"                  
#>  [7] "max.depth"                    "min.node.size"               
#>  [9] "min.prop"                     "minprop"                     
#> [11] "mtry"                         "mtry.ratio"                  
#> [13] "num.random.splits"            "num.threads"                 
#> [15] "num.trees"                    "oob.error"                   
#> [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"