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 20.14%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 61 18
#> R 10 50
print(learner$importance())
#> V12 V11 V9 V10 V13
#> 1.194818e-01 1.041394e-01 9.758721e-02 7.748899e-02 6.647699e-02
#> V51 V36 V49 V47 V21
#> 6.489757e-02 6.216207e-02 5.662002e-02 5.240531e-02 5.184806e-02
#> V52 V20 V35 V43 V15
#> 4.863309e-02 4.429052e-02 4.296893e-02 3.976769e-02 3.852092e-02
#> V48 V46 V45 V44 V4
#> 3.846530e-02 3.788620e-02 3.747527e-02 3.698609e-02 3.675456e-02
#> V22 V37 V28 V17 V18
#> 3.610444e-02 3.505666e-02 3.434807e-02 3.341631e-02 3.174194e-02
#> V59 V32 V56 V1 V5
#> 3.063505e-02 2.959623e-02 2.696650e-02 2.676398e-02 2.637304e-02
#> V2 V31 V24 V23 V16
#> 2.480618e-02 2.295906e-02 2.246918e-02 2.153217e-02 2.129260e-02
#> V8 V50 V34 V19 V14
#> 2.017047e-02 2.010803e-02 1.993683e-02 1.779979e-02 1.648998e-02
#> V30 V25 V27 V7 V3
#> 1.599788e-02 1.526413e-02 1.476583e-02 1.444432e-02 1.441354e-02
#> V29 V38 V33 V6 V60
#> 1.437892e-02 1.424700e-02 1.374932e-02 1.215247e-02 1.071915e-02
#> V55 V41 V39 V42 V26
#> 9.157232e-03 7.950625e-03 7.637357e-03 6.816803e-03 4.948356e-03
#> V54 V53 V40 V57 V58
#> 4.276020e-03 2.084285e-03 1.092825e-03 2.252168e-05 -2.747173e-03
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.1304348