Feature Selection Wrapper

Feature selection wrappers can be found in the mlr3fselect packages. The goal is to find the best subset of features with respect to a performance measure in an iterative fashion.

Example Usage

Run a sequential feature selection on the Pima Indian Diabetes data set.

library(mlr3verse)

# retrieve task
task = tsk("pima")

# load learner
learner = lrn("classif.rpart")

# feature selection on the pima indians diabetes data set
instance = fselect(
  fselector = fs("sequential"),
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce")
)

# best performing feature subset
instance$result
      age glucose insulin   mass pedigree pregnant pressure triceps features
   <lgcl>  <lgcl>  <lgcl> <lgcl>   <lgcl>   <lgcl>   <lgcl>  <lgcl>   <list>
1:  FALSE    TRUE   FALSE  FALSE    FALSE    FALSE    FALSE   FALSE  glucose
   n_features classif.ce
        <int>      <num>
1:          1  0.2617188
# subset the task and fit the final model
task$select(instance$result_feature_set)
learner$train(task)

print(learner)
<LearnerClassifRpart:classif.rpart>: Classification Tree
* Model: rpart
* Parameters: xval=0
* Packages: mlr3, rpart
* Predict Types:  [response], prob
* Feature Types: logical, integer, numeric, factor, ordered
* Properties: importance, missings, multiclass, selected_features,
  twoclass, weights