FSelectorRFE: Feature Selection via Recursive Feature Elimination

Description Dictionary Parameters Super class Public fields Methods Examples

Description

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.

Dictionary

This FSelector can be instantiated via the dictionary mlr_fselectors or with the associated sugar function fs():

1
2
mlr_fselectors$get("rfe")
fs("rfe")

Parameters

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.

Super class

mlr3fselect::FSelector -> FSelectorRFE

Public fields

importance

numeric()
Stores the feature importance of the model with all variables if recrusive is set to FALSE

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
FSelectorRFE$new()

Method clone()

The objects of this class are cloneable with this method.

Usage
FSelectorRFE$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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")

# Modifies the instance by reference
fselector$optimize(instance)

# Returns best scoring evaluation
instance$result

# Allows access of data.table of full path of all evaluations
as.data.table(instance$archive)

mlr3fselect documentation built on March 9, 2021, 5:06 p.m.