Skip to contents

Ensemble 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: FALSE

    • Initial value: "simple"

    • Reason for change: The default value of FALSE will resolve to "none", which turns importance calculation off. To enable importance calculation by default, importance is set to "simple".

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.rFerns")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”

  • Feature Types: “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3extralearners, rFerns

Parameters

IdTypeDefaultLevelsRange
consistentSeeduntypedNULL-
depthinteger5\([1, 16]\)
fernsinteger1000\((-\infty, \infty)\)
importanceuntypedFALSE-
saveForestlogicalTRUETRUE, FALSE-
threadsinteger0\((-\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

Author

annanzrv

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifRferns

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method importance()

The importance scores are extracted from the model slot importance.

Usage

LearnerClassifRferns$importance()

Returns

Named numeric().


Method oob_error()

OOB error is extracted from the model slot oobErr.

Usage

LearnerClassifRferns$oob_error()

Returns

numeric(1).


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifRferns$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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 20.14%; OOB confusion matrix:
#>          True
#> Predicted  M  R
#>         M 61 18
#>         R 10 50
print(learner$importance())
#>           V12           V11            V9           V10           V13 
#>  1.194818e-01  1.041394e-01  9.758721e-02  7.748899e-02  6.647699e-02 
#>           V51           V36           V49           V47           V21 
#>  6.489757e-02  6.216207e-02  5.662002e-02  5.240531e-02  5.184806e-02 
#>           V52           V20           V35           V43           V15 
#>  4.863309e-02  4.429052e-02  4.296893e-02  3.976769e-02  3.852092e-02 
#>           V48           V46           V45           V44            V4 
#>  3.846530e-02  3.788620e-02  3.747527e-02  3.698609e-02  3.675456e-02 
#>           V22           V37           V28           V17           V18 
#>  3.610444e-02  3.505666e-02  3.434807e-02  3.341631e-02  3.174194e-02 
#>           V59           V32           V56            V1            V5 
#>  3.063505e-02  2.959623e-02  2.696650e-02  2.676398e-02  2.637304e-02 
#>            V2           V31           V24           V23           V16 
#>  2.480618e-02  2.295906e-02  2.246918e-02  2.153217e-02  2.129260e-02 
#>            V8           V50           V34           V19           V14 
#>  2.017047e-02  2.010803e-02  1.993683e-02  1.779979e-02  1.648998e-02 
#>           V30           V25           V27            V7            V3 
#>  1.599788e-02  1.526413e-02  1.476583e-02  1.444432e-02  1.441354e-02 
#>           V29           V38           V33            V6           V60 
#>  1.437892e-02  1.424700e-02  1.374932e-02  1.215247e-02  1.071915e-02 
#>           V55           V41           V39           V42           V26 
#>  9.157232e-03  7.950625e-03  7.637357e-03  6.816803e-03  4.948356e-03 
#>           V54           V53           V40           V57           V58 
#>  4.276020e-03  2.084285e-03  1.092825e-03  2.252168e-05 -2.747173e-03 

# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
#> classif.ce 
#>  0.1304348