Random Ferns Classification Learner
Source:R/learner_rFerns_classif_rFerns.R
mlr_learners_classif.rFerns.Rd
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"
.
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/basics.html#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()
Method 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'
# 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.99%; OOB confusion matrix:
#> True
#> Predicted M R
#> M 63 15
#> R 10 51
print(learner$importance())
#> V11 V12 V10 V9 V48 V49
#> 0.131089139 0.126331033 0.107695622 0.104824541 0.056995939 0.056157002
#> V13 V21 V45 V20 V51 V47
#> 0.054748949 0.044979828 0.044672756 0.043066992 0.039709420 0.039651820
#> V4 V31 V23 V28 V46 V5
#> 0.037608677 0.035833571 0.034148094 0.033914734 0.032406494 0.028682662
#> V42 V43 V35 V27 V36 V52
#> 0.028326446 0.026663317 0.026243445 0.026090717 0.025383180 0.025346051
#> V22 V16 V32 V44 V17 V1
#> 0.024806669 0.024524480 0.024080261 0.023358910 0.022449848 0.020645827
#> V37 V8 V40 V50 V26 V39
#> 0.020538476 0.018419734 0.018016194 0.016618824 0.016269067 0.015665298
#> V18 V54 V6 V57 V29 V58
#> 0.015381371 0.015034028 0.014735852 0.014490032 0.014081677 0.013796544
#> V34 V2 V60 V24 V53 V14
#> 0.012181402 0.011560012 0.010474450 0.010081060 0.010049808 0.009910333
#> V3 V38 V25 V56 V33 V15
#> 0.008996845 0.008822143 0.007843442 0.007734675 0.007523179 0.007242487
#> V19 V41 V7 V30 V59 V55
#> 0.006334991 0.006035035 0.004984686 0.003931948 0.003399997 0.002772569
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.173913