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 19.42%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 61 12
#> R 15 51
print(learner$importance())
#> V11 V10 V12 V9 V48
#> 0.1448657321 0.1101732547 0.1004941368 0.1002680002 0.0785811578
#> V49 V13 V5 V46 V27
#> 0.0692506982 0.0624192615 0.0558659813 0.0555156450 0.0539710005
#> V28 V45 V4 V47 V51
#> 0.0512145231 0.0500064648 0.0476002304 0.0463971364 0.0447021603
#> V52 V20 V44 V1 V15
#> 0.0442863145 0.0426728967 0.0421767123 0.0388197602 0.0354814439
#> V29 V43 V21 V22 V18
#> 0.0354565137 0.0350017434 0.0345897183 0.0331482090 0.0311564658
#> V2 V14 V35 V31 V56
#> 0.0303186016 0.0296432363 0.0296390334 0.0265175260 0.0258249025
#> V30 V17 V19 V16 V8
#> 0.0255908332 0.0254641871 0.0226565740 0.0224721619 0.0221557319
#> V37 V36 V6 V23 V59
#> 0.0213203563 0.0210313952 0.0203605451 0.0195029920 0.0193344600
#> V25 V34 V24 V33 V50
#> 0.0187152115 0.0181698556 0.0175911358 0.0167312283 0.0152690195
#> V3 V41 V7 V54 V38
#> 0.0139767857 0.0136127807 0.0119393029 0.0111737937 0.0102547996
#> V42 V26 V60 V32 V39
#> 0.0101535084 0.0097436315 0.0092574701 0.0077679687 0.0064794039
#> V58 V55 V40 V53 V57
#> 0.0046649294 0.0040422498 -0.0002095510 -0.0007096132 -0.0062863757
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2028986