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 17.27%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 61 9
#> R 15 54
print(learner$importance())
#> V11 V12 V10 V49 V9
#> 1.227722e-01 8.762141e-02 8.352180e-02 7.628189e-02 6.927153e-02
#> V4 V36 V13 V48 V46
#> 5.538939e-02 5.394170e-02 5.310194e-02 5.024282e-02 4.961971e-02
#> V37 V52 V28 V45 V51
#> 4.899797e-02 4.839191e-02 4.811835e-02 4.519928e-02 3.951891e-02
#> V21 V8 V27 V44 V35
#> 3.682516e-02 3.635998e-02 3.602431e-02 3.545363e-02 3.540363e-02
#> V47 V17 V20 V43 V5
#> 3.474331e-02 3.458204e-02 3.447513e-02 3.235667e-02 3.104644e-02
#> V16 V29 V23 V22 V1
#> 3.028009e-02 2.687828e-02 2.508728e-02 2.507841e-02 2.461971e-02
#> V39 V15 V6 V59 V31
#> 2.276969e-02 2.151746e-02 2.064755e-02 1.850470e-02 1.833004e-02
#> V24 V58 V26 V34 V56
#> 1.811396e-02 1.765365e-02 1.692605e-02 1.557529e-02 1.411054e-02
#> V3 V14 V41 V18 V32
#> 1.392319e-02 1.385944e-02 1.380671e-02 1.361593e-02 1.332073e-02
#> V19 V2 V25 V40 V54
#> 1.062486e-02 1.054128e-02 9.713047e-03 9.414268e-03 7.624795e-03
#> V55 V42 V30 V33 V38
#> 7.250348e-03 6.356999e-03 5.497198e-03 3.694044e-03 2.016066e-03
#> V7 V50 V60 V57 V53
#> 8.485920e-04 -6.745578e-05 -4.701210e-04 -7.543224e-04 -6.398348e-03
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2028986