Movatterモバイル変換


[0]ホーム

URL:


Skip to contents

Ranger Classification Learner

Source:R/LearnerClassifRanger.R
mlr_learners_classif.ranger.Rd

Random classification forest.Callsranger::ranger() from packageranger.

Custom mlr3 parameters

  • mtry:

    • This hyperparameter can alternatively be set via our hyperparametermtry.ratioasmtry = max(ceiling(mtry.ratio * n_features), 1).Note thatmtry andmtry.ratio are mutually exclusive.

Initial parameter values

  • num.threads:

    • Actual default:2, using two threads, while also respecting environment variableR_RANGER_NUM_THREADS,options(ranger.num.threads = N), oroptions(Ncpus = N), withprecedence in that order.

    • Adjusted value: 1.

    • Reason for change: Conflicting with parallelization viafuture.

Dictionary

Thismlr3::Learner can be instantiated via thedictionarymlr3::mlr_learners or with the associated sugar functionmlr3::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
always.split.variablesuntyped--
class.weightsuntypedNULL-
holdoutlogicalFALSETRUE, FALSE-
importancecharacter-none, impurity, impurity_corrected, permutation-
keep.inbaglogicalFALSETRUE, FALSE-
max.depthintegerNULL\([1, \infty)\)
min.bucketuntyped1L-
min.node.sizeuntypedNULL-
mtryinteger-\([1, \infty)\)
mtry.rationumeric-\([0, 1]\)
na.actioncharacterna.learnna.learn, na.omit, na.fail-
num.random.splitsinteger1\([1, \infty)\)
node.statslogicalFALSETRUE, FALSE-
num.threadsinteger1\([1, \infty)\)
num.treesinteger500\([1, \infty)\)
oob.errorlogicalTRUETRUE, FALSE-
regularization.factoruntyped1-
regularization.usedepthlogicalFALSETRUE, FALSE-
replacelogicalTRUETRUE, FALSE-
respect.unordered.factorscharacter-ignore, order, partition-
sample.fractionnumeric-\([0, 1]\)
save.memorylogicalFALSETRUE, FALSE-
scale.permutation.importancelogicalFALSETRUE, FALSE-
seedintegerNULL\((-\infty, \infty)\)
split.select.weightsuntypedNULL-
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

Public methods

Inherited methods


Methodnew()

Creates a new instance of thisR6 class.


Methodimportance()

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

Usage

LearnerClassifRanger$importance()

Returns

Namednumeric().


Methodoob_error()

The out-of-bag error, extracted from model slotprediction.error.

Usage

LearnerClassifRanger$oob_error()

Returns

numeric(1).


Methodselected_features()

The set of features used for node splitting in the forest.

Usage

LearnerClassifRanger$selected_features()

Returns

character().


Methodclone()

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)){# Define the Learner and set parameter valueslearner=lrn("classif.ranger")print(learner)# Define a Tasktask=tsk("sonar")# Create train and test setids=partition(task)# Train the learner on the training idslearner$train(task, row_ids=ids$train)# print the modelprint(learner$model)# importance methodif("importance"%in%learner$properties)print(learner$importance)# Make predictions for the test rowspredictions=learner$predict(task, row_ids=ids$test)# Score the predictionspredictions$score()}#> <LearnerClassifRanger:classif.ranger>: Random Forest#> * 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, missings, multiclass,#>   oob_error, selected_features, twoclass, weights#> Ranger result#>#> Call:#>  ranger::ranger(dependent.variable.name = task$target_names, data = task$data(),      probability = self$predict_type == "prob", num.threads = 1L)#>#> Type:                             Classification#> Number of trees:                  500#> Sample size:                      139#> Number of independent variables:  60#> Mtry:                             7#> Target node size:                 1#> Variable importance mode:         none#> Splitrule:                        gini#> OOB prediction error:             19.42 %#> function ()#> .__LearnerClassifRanger__importance(self = self, private = private,#>     super = super)#> <environment: 0x559c03c87ad8>#> classif.ce#>   0.173913

[8]ページ先頭

©2009-2025 Movatter.jp