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/chapters/chapter2/data_and_basic_modeling.html#sec-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', predict_raw = 'FALSE'
# 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.86%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 61 15
#> R 14 49
print(learner$importance())
#> V11 V10 V12 V49 V9
#> 0.1257627473 0.1177859903 0.1098601904 0.0919697992 0.0872788348
#> V13 V48 V36 V45 V37
#> 0.0776603866 0.0755111871 0.0556968022 0.0545658723 0.0494081897
#> V21 V46 V47 V8 V51
#> 0.0458814318 0.0449908427 0.0444125068 0.0414685991 0.0384909588
#> V14 V4 V20 V31 V19
#> 0.0383671061 0.0375770500 0.0368118141 0.0361032582 0.0358069539
#> V52 V35 V5 V16 V43
#> 0.0353280413 0.0329058482 0.0322630275 0.0277176788 0.0271091882
#> V30 V26 V56 V2 V23
#> 0.0257718883 0.0255527637 0.0245456970 0.0239315574 0.0227597746
#> V33 V27 V29 V58 V28
#> 0.0226663105 0.0225810120 0.0222244550 0.0217837876 0.0196306827
#> V57 V1 V24 V18 V17
#> 0.0194668039 0.0193175283 0.0192713495 0.0191650589 0.0185773997
#> V15 V7 V44 V22 V32
#> 0.0182465170 0.0178666247 0.0176297496 0.0166111996 0.0163217010
#> V53 V6 V59 V39 V3
#> 0.0153894692 0.0153527530 0.0143897606 0.0134175575 0.0128243435
#> V38 V25 V42 V34 V55
#> 0.0127384338 0.0113087661 0.0112312650 0.0099898591 0.0038772058
#> V50 V60 V54 V41 V40
#> 0.0027753716 0.0014192234 -0.0000232206 -0.0055200915 -0.0136896140
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2753623