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()
LearnerClassifRferns$new()
Creates a new instance of this R6 class.
Usage
LearnerClassifRferns$new()LearnerClassifRferns$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.14%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 63 17
#> R 11 48
print(learner$importance())
#> V11 V12 V10 V9 V36
#> 0.1629945192 0.1371393534 0.1195580328 0.0980889172 0.0681149272
#> V13 V48 V47 V49 V21
#> 0.0680247357 0.0606668072 0.0500019587 0.0465285231 0.0427804855
#> V37 V35 V20 V4 V19
#> 0.0421735351 0.0387993265 0.0385042664 0.0377329028 0.0357671727
#> V29 V28 V22 V15 V8
#> 0.0357292543 0.0355128401 0.0354132206 0.0337812303 0.0334883671
#> V43 V6 V16 V45 V51
#> 0.0320823980 0.0310301920 0.0303289380 0.0285626807 0.0283170868
#> V27 V26 V14 V3 V23
#> 0.0276960898 0.0274189078 0.0268994155 0.0268391491 0.0266741578
#> V5 V52 V30 V24 V1
#> 0.0265115007 0.0263158017 0.0251067961 0.0238916956 0.0238774385
#> V46 V50 V31 V18 V42
#> 0.0233063840 0.0228390785 0.0215882824 0.0207836081 0.0184507134
#> V38 V44 V7 V59 V60
#> 0.0184442276 0.0166051547 0.0156376830 0.0155249233 0.0133486272
#> V55 V54 V2 V57 V17
#> 0.0133005014 0.0123412022 0.0109682762 0.0105350126 0.0101093025
#> V34 V32 V41 V33 V53
#> 0.0086342911 0.0078207893 0.0064809346 0.0057445560 0.0055172523
#> V40 V58 V25 V56 V39
#> 0.0014323252 0.0006600937 -0.0010112054 -0.0011708156 -0.0036876929
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2173913