Random Ferns Classification Learner
Source:R/learner_rFerns_classif_rFerns.R
mlr_learners_classif.rFerns.RdEnsemble machine learning algorithm based on Random Ferns, which are a simplified,
faster alternative to Random Forests.
Calls rFerns::rFerns() from rFerns.
Initial parameter values
importance:Actual default:
FALSEInitial value:
"simple"Reason for change: The default value of
FALSEwill resolve to "none", which turns importance calculation off. To enable importance calculation by default,importanceis set to"simple".
Meta Information
Task type: “classif”
Predict Types: “response”
Feature Types: “integer”, “numeric”, “factor”, “ordered”
Required Packages: mlr3, mlr3extralearners, rFerns
Parameters
| Id | Type | Default | Levels | Range |
| consistentSeed | untyped | NULL | - | |
| depth | integer | 5 | \([1, 16]\) | |
| ferns | integer | 1000 | \((-\infty, \infty)\) | |
| importance | untyped | FALSE | - | |
| saveForest | logical | TRUE | TRUE, FALSE | - |
| threads | integer | 0 | \((-\infty, \infty)\) |
References
Kursa MB (2014). “rFerns: An Implementation of the Random Ferns Method for General-Purpose Machine Learning.” Journal of Statistical Software, 61(10), 1–13. https://www.jstatsoft.org/v61/i10/.
Ozuysal, Mustafa, Calonder, Michael, Lepetit, Vincent, Fua, Pascal (2010). “Fast Keypoint Recognition Using Random Ferns.” IEEE Transactions on Pattern Analysis and Machine Intelligence, 32(3), 448-461. doi:10.1109/TPAMI.2009.23 .
See also
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.
Super classes
mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifRferns
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$format()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$print()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3::LearnerClassif$predict_newdata_fast()
Method importance()
The importance scores are extracted from the model slot importance.
Returns
Named numeric().
Examples
# Define the Learner
learner = lrn("classif.rFerns")
print(learner)
#>
#> ── <LearnerClassifRferns> (classif.rFerns): Random Ferns Classifier ────────────
#> • Model: -
#> • Parameters: importance=simple
#> • Packages: mlr3, mlr3extralearners, and rFerns
#> • Predict Types: [response]
#> • Feature Types: integer, numeric, factor, and ordered
#> • Encapsulation: none (fallback: -)
#> • Properties: importance, multiclass, oob_error, and twoclass
#> • Other settings: use_weights = 'error'
# Define a Task
task = tsk("sonar")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
print(learner$model)
#>
#> Forest of 1000 ferns of a depth 5.
#>
#> OOB error 17.27%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 65 11
#> R 13 50
print(learner$importance())
#> V11 V10 V9 V49 V48
#> 1.082406e-01 1.006903e-01 9.021358e-02 8.802302e-02 8.244788e-02
#> V12 V13 V36 V46 V21
#> 8.200642e-02 7.060736e-02 5.542505e-02 5.430061e-02 5.073568e-02
#> V45 V20 V37 V47 V35
#> 5.034828e-02 4.086553e-02 3.829384e-02 3.753808e-02 2.818832e-02
#> V28 V44 V1 V19 V23
#> 2.802669e-02 2.717660e-02 2.595274e-02 2.559450e-02 2.508379e-02
#> V22 V32 V5 V43 V29
#> 2.503492e-02 2.443916e-02 2.320307e-02 2.170318e-02 2.127811e-02
#> V51 V15 V27 V52 V24
#> 1.882539e-02 1.864240e-02 1.742279e-02 1.678782e-02 1.647563e-02
#> V26 V18 V31 V41 V60
#> 1.589019e-02 1.520710e-02 1.421891e-02 1.367999e-02 1.343816e-02
#> V4 V17 V8 V3 V14
#> 1.337975e-02 1.333121e-02 1.312740e-02 1.269011e-02 1.266965e-02
#> V42 V38 V55 V54 V50
#> 1.160549e-02 1.156727e-02 1.068524e-02 9.850290e-03 9.729259e-03
#> V2 V56 V58 V16 V25
#> 8.766584e-03 8.526964e-03 7.618198e-03 6.256473e-03 6.081066e-03
#> V34 V33 V7 V6 V59
#> 4.798155e-03 4.457976e-03 3.950702e-03 3.333336e-03 3.243638e-03
#> V53 V40 V30 V39 V57
#> 1.320183e-03 8.150895e-04 -6.230425e-05 -9.979730e-04 -1.506252e-03
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.1449275