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 17.27%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 63 15
#> R 9 52
print(learner$importance())
#> V12 V11 V9 V10 V49 V36
#> 0.123259590 0.099125616 0.081870867 0.076620630 0.068546450 0.060398844
#> V47 V48 V21 V13 V31 V46
#> 0.053019976 0.052855814 0.051048894 0.049307576 0.047977674 0.045381497
#> V20 V37 V35 V45 V51 V43
#> 0.043541528 0.042225583 0.041784664 0.040580893 0.039113749 0.037733681
#> V17 V22 V14 V4 V42 V15
#> 0.035755128 0.034357372 0.034238752 0.033176269 0.032308745 0.031998603
#> V23 V44 V8 V30 V5 V32
#> 0.031858850 0.031115113 0.027057592 0.026966712 0.026644376 0.025808526
#> V2 V41 V19 V24 V57 V1
#> 0.022570397 0.020315370 0.019880125 0.019731670 0.019677578 0.019638551
#> V54 V33 V39 V29 V34 V18
#> 0.019565908 0.018891638 0.018516543 0.018301420 0.018236421 0.018069539
#> V16 V59 V26 V52 V28 V50
#> 0.015837826 0.015121843 0.014087832 0.014043933 0.013438668 0.013106012
#> V58 V27 V7 V38 V53 V3
#> 0.012468120 0.012064149 0.011006539 0.009780137 0.009088357 0.008905590
#> V6 V40 V56 V60 V55 V25
#> 0.008829446 0.006861116 0.005836554 0.005114090 0.004450283 0.003522600
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.1594203