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 18.71%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 65 19
#> R 7 48
print(learner$importance())
#> V11 V49 V10 V9 V12
#> 0.1154899324 0.0798157328 0.0761385473 0.0756659177 0.0615494432
#> V51 V47 V48 V36 V21
#> 0.0571514400 0.0531301121 0.0513046905 0.0459481387 0.0459433466
#> V28 V19 V20 V4 V13
#> 0.0423326233 0.0418634525 0.0406542580 0.0394311932 0.0376933970
#> V45 V52 V46 V23 V15
#> 0.0376837042 0.0356243343 0.0346729231 0.0338117218 0.0327081266
#> V35 V31 V22 V37 V27
#> 0.0319049153 0.0310599737 0.0293807773 0.0291548783 0.0282243193
#> V16 V29 V32 V42 V5
#> 0.0273781724 0.0269716121 0.0268135379 0.0266124252 0.0248911830
#> V44 V58 V34 V6 V38
#> 0.0221212177 0.0220140657 0.0219576527 0.0214080039 0.0210258969
#> V39 V14 V2 V25 V8
#> 0.0199355230 0.0185487377 0.0173994618 0.0173362525 0.0170858205
#> V17 V43 V59 V24 V26
#> 0.0170655980 0.0167548036 0.0157301417 0.0154627913 0.0137067883
#> V54 V18 V40 V3 V33
#> 0.0131125814 0.0129739057 0.0115658566 0.0094688116 0.0092618998
#> V55 V1 V56 V41 V53
#> 0.0081266975 0.0081098586 0.0080874022 0.0078167412 0.0072819316
#> V30 V60 V50 V7 V57
#> 0.0070840185 0.0063483852 0.0059049416 -0.0005975822 -0.0039134527
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.1594203