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 22.30%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 59 14
#> R 17 49
print(learner$importance())
#> V12 V11 V10 V9 V13
#> 1.162980e-01 1.103730e-01 9.740880e-02 9.425460e-02 6.894428e-02
#> V49 V48 V21 V44 V20
#> 6.465448e-02 5.460105e-02 4.784094e-02 4.632376e-02 4.321608e-02
#> V51 V27 V37 V45 V35
#> 4.247069e-02 4.180416e-02 3.978427e-02 3.346462e-02 3.258070e-02
#> V28 V34 V22 V47 V23
#> 3.242703e-02 3.234935e-02 3.187369e-02 3.045901e-02 3.030010e-02
#> V14 V46 V36 V4 V39
#> 3.025649e-02 2.882914e-02 2.774260e-02 2.741076e-02 2.638650e-02
#> V31 V32 V29 V8 V1
#> 2.576748e-02 2.449125e-02 2.433348e-02 2.402279e-02 2.318048e-02
#> V43 V52 V33 V18 V24
#> 2.273402e-02 2.249895e-02 2.218064e-02 2.125010e-02 2.111666e-02
#> V15 V7 V60 V16 V19
#> 2.026987e-02 1.994046e-02 1.983310e-02 1.605155e-02 1.536508e-02
#> V2 V5 V26 V38 V6
#> 1.489893e-02 1.217494e-02 1.180421e-02 1.051864e-02 1.024478e-02
#> V30 V58 V17 V3 V42
#> 9.632549e-03 9.520562e-03 9.368892e-03 6.347842e-03 6.218906e-03
#> V59 V56 V25 V53 V55
#> 4.430941e-03 4.009241e-03 3.200032e-03 1.791853e-03 1.724902e-03
#> V54 V50 V41 V40 V57
#> 9.396293e-04 -2.650869e-05 -5.101303e-04 -2.625843e-03 -5.878992e-03
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.1449275