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 17.27%; OOB confusion matrix:
#>          True
#> Predicted  M  R
#>         M 61  9
#>         R 15 54
print(learner$importance())
#>           V11           V12           V10           V49            V9 
#>  1.227722e-01  8.762141e-02  8.352180e-02  7.628189e-02  6.927153e-02 
#>            V4           V36           V13           V48           V46 
#>  5.538939e-02  5.394170e-02  5.310194e-02  5.024282e-02  4.961971e-02 
#>           V37           V52           V28           V45           V51 
#>  4.899797e-02  4.839191e-02  4.811835e-02  4.519928e-02  3.951891e-02 
#>           V21            V8           V27           V44           V35 
#>  3.682516e-02  3.635998e-02  3.602431e-02  3.545363e-02  3.540363e-02 
#>           V47           V17           V20           V43            V5 
#>  3.474331e-02  3.458204e-02  3.447513e-02  3.235667e-02  3.104644e-02 
#>           V16           V29           V23           V22            V1 
#>  3.028009e-02  2.687828e-02  2.508728e-02  2.507841e-02  2.461971e-02 
#>           V39           V15            V6           V59           V31 
#>  2.276969e-02  2.151746e-02  2.064755e-02  1.850470e-02  1.833004e-02 
#>           V24           V58           V26           V34           V56 
#>  1.811396e-02  1.765365e-02  1.692605e-02  1.557529e-02  1.411054e-02 
#>            V3           V14           V41           V18           V32 
#>  1.392319e-02  1.385944e-02  1.380671e-02  1.361593e-02  1.332073e-02 
#>           V19            V2           V25           V40           V54 
#>  1.062486e-02  1.054128e-02  9.713047e-03  9.414268e-03  7.624795e-03 
#>           V55           V42           V30           V33           V38 
#>  7.250348e-03  6.356999e-03  5.497198e-03  3.694044e-03  2.016066e-03 
#>            V7           V50           V60           V57           V53 
#>  8.485920e-04 -6.745578e-05 -4.701210e-04 -7.543224e-04 -6.398348e-03 

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

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