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 19.42%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 60 17
#> R 10 52
print(learner$importance())
#> V12 V11 V9 V10 V45 V4
#> 0.105194594 0.102770295 0.091498342 0.089577562 0.072980499 0.062939083
#> V48 V49 V46 V47 V13 V51
#> 0.061350196 0.055485613 0.054751434 0.052775415 0.052336388 0.051444843
#> V36 V8 V27 V28 V18 V5
#> 0.051368632 0.047475191 0.043639016 0.043498291 0.041692739 0.041469106
#> V35 V6 V52 V1 V16 V44
#> 0.036830746 0.036074687 0.035441909 0.034188044 0.033339314 0.030593524
#> V17 V37 V29 V43 V3 V20
#> 0.029733008 0.029369142 0.028924801 0.027703255 0.026257748 0.025303145
#> V19 V39 V21 V15 V38 V7
#> 0.024952396 0.020102946 0.019889136 0.019478827 0.018103397 0.017353551
#> V58 V53 V31 V2 V14 V41
#> 0.017262480 0.017166173 0.015918749 0.015718309 0.015497326 0.014910917
#> V22 V54 V32 V59 V23 V56
#> 0.014292822 0.014091817 0.012739955 0.011370769 0.010039442 0.009317441
#> V26 V33 V30 V57 V50 V55
#> 0.008509531 0.007931494 0.007511433 0.007105539 0.006027573 0.005686036
#> V34 V24 V40 V25 V60 V42
#> 0.005466126 0.005425540 0.005277734 0.004594576 0.001996738 -0.003060453
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2608696