FSelectorRFE
class that implements Recursive Feature Elimination (RFE). The
recursive algorithm (recursive = TRUE
) recomputes the feature importance
on the reduced feature set in every iteration. The non-recursive algorithm
(recursive = FALSE
) only uses the feature importance of the model fitted
with all features to eliminate the next most unimportant features in every
iteration.
This FSelector can be instantiated via the dictionary
mlr_fselectors or with the associated sugar function fs()
:
mlr_fselectors$get("rfe") fs("rfe")
min_features
integer(1)
The minimum number of features to select, default is 1L
.
feature_fraction
double(1)
Fraction of features to retain in each iteration, default is 0.5
.
feature_number
integer(1)
Number of features to remove in each iteration.
subset_sizes
integer()
Vector of number of features to retain in each iteration. Must be sorted in
decreasing order.
recursive
logical(1)
Use the recursive version? Default is FALSE
.
The parameter feature_fraction
, feature_number
and subset_sizes
are
mutually exclusive.
mlr3fselect::FSelector
-> FSelectorRFE
importance
numeric()
Stores the feature importance of the model with all variables if
recrusive
is set to FALSE
new()
Creates a new instance of this R6 class.
FSelectorRFE$new()
clone()
The objects of this class are cloneable with this method.
FSelectorRFE$clone(deep = FALSE)
deep
Whether to make a deep clone.
library(mlr3) terminator = trm("evals", n_evals = 10) instance = FSelectInstanceSingleCrit$new( task = tsk("iris"), learner = lrn("classif.rpart"), resampling = rsmp("holdout"), measure = msr("classif.ce"), terminator = terminator, store_models = TRUE ) fselector = fs("rfe") # \donttest{ # Modifies the instance by reference fselector$optimize(instance)#> Petal.Length Petal.Width Sepal.Length Sepal.Width #> 1: TRUE TRUE TRUE TRUE #> features x_domain classif.ce #> 1: Petal.Length,Petal.Width,Sepal.Length,Sepal.Width <list[4]> 0.1# Returns best scoring evaluation instance$result#> Petal.Length Petal.Width Sepal.Length Sepal.Width #> 1: TRUE TRUE TRUE TRUE #> features x_domain classif.ce #> 1: Petal.Length,Petal.Width,Sepal.Length,Sepal.Width <list[4]> 0.1#> Petal.Length Petal.Width Sepal.Length Sepal.Width classif.ce #> 1: TRUE TRUE TRUE TRUE 0.1 #> 2: TRUE TRUE FALSE FALSE 0.1 #> 3: TRUE FALSE FALSE FALSE 0.1 #> uhash timestamp batch_nr #> 1: 3d438e10-301e-4bdb-802b-32d3f0f86374 2021-01-18 04:56:33 1 #> 2: 7c99b08c-a57a-4f37-a611-7c79cce972dd 2021-01-18 04:56:34 2 #> 3: f3b0e443-a86a-4336-a8ba-dab9a5333a22 2021-01-18 04:56:34 3 #> importance x_domain_Petal.Length #> 1: 62.59806,57.02905,40.71675,25.19926 TRUE #> 2: 62.59806,57.02905 TRUE #> 3: 62.59806 TRUE #> x_domain_Petal.Width x_domain_Sepal.Length x_domain_Sepal.Width #> 1: TRUE TRUE TRUE #> 2: TRUE FALSE FALSE #> 3: FALSE FALSE FALSE