mlr_learners_classif.randomForest | R Documentation |
Random forest for classification.
Calls randomForest::randomForest()
from randomForest.
This Learner can be instantiated via lrn():
lrn("classif.randomForest")
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”
Required Packages: mlr3, mlr3extralearners, randomForest
Id | Type | Default | Levels | Range |
ntree | integer | 500 | [1, \infty) |
|
mtry | integer | - | [1, \infty) |
|
replace | logical | TRUE | TRUE, FALSE | - |
classwt | untyped | NULL | - | |
cutoff | untyped | - | - | |
strata | untyped | - | - | |
sampsize | untyped | - | - | |
nodesize | integer | 1 | [1, \infty) |
|
maxnodes | integer | - | [1, \infty) |
|
importance | character | FALSE | accuracy, gini, 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 | - |
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifRandomForest
new()
Creates a new instance of this R6 class.
LearnerClassifRandomForest$new()
importance()
The importance scores are extracted from the slot importance
.
Parameter 'importance' must be set to either "accuracy"
or "gini"
.
LearnerClassifRandomForest$importance()
Named numeric()
.
oob_error()
OOB errors are extracted from the model slot err.rate
.
LearnerClassifRandomForest$oob_error()
numeric(1)
.
clone()
The objects of this class are cloneable with this method.
LearnerClassifRandomForest$clone(deep = FALSE)
deep
Whether to make a deep clone.
pat-s
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")}.
Dictionary of Learners: mlr3::mlr_learners.
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).
Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
# Define the Learner
learner = mlr3::lrn("classif.randomForest", importance = "accuracy")
print(learner)
# Define a Task
task = mlr3::tsk("sonar")
# 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.