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 15.11%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 67 12
#> R 9 51
print(learner$importance())
#> V12 V11 V10 V49 V36
#> 0.1696690250 0.1239414018 0.0938357977 0.0776508394 0.0762110943
#> V48 V9 V47 V37 V13
#> 0.0742216134 0.0710068402 0.0699791040 0.0568867726 0.0552448018
#> V51 V5 V22 V45 V35
#> 0.0508254004 0.0500656291 0.0485159302 0.0424811321 0.0390120884
#> V20 V52 V21 V46 V15
#> 0.0374199617 0.0368451875 0.0364735532 0.0340809078 0.0328392319
#> V29 V6 V14 V1 V4
#> 0.0310680989 0.0310349575 0.0293554815 0.0292340384 0.0288205994
#> V42 V30 V27 V26 V28
#> 0.0283134125 0.0264494417 0.0262518133 0.0259500362 0.0256219617
#> V43 V34 V16 V38 V23
#> 0.0255837273 0.0254172312 0.0243354767 0.0229928520 0.0226114855
#> V17 V31 V8 V55 V59
#> 0.0213943695 0.0210812019 0.0206300011 0.0201096765 0.0197214681
#> V44 V50 V19 V32 V57
#> 0.0190430392 0.0182117850 0.0172992187 0.0137333880 0.0116108696
#> V24 V33 V54 V60 V39
#> 0.0110970384 0.0089557705 0.0086017529 0.0077439334 0.0075314202
#> V25 V7 V41 V53 V18
#> 0.0066708334 0.0065984766 0.0051400220 0.0047675011 0.0021651190
#> V2 V58 V3 V56 V40
#> 0.0009691677 -0.0002198514 -0.0010952942 -0.0016452771 -0.0023126046
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.173913