Skip to contents

Feature Selection using the Exhaustive Search Algorithm. Exhaustive Search generates all possible feature sets.

Details

The feature selection terminates itself when all feature sets are evaluated. It is not necessary to set a termination criterion.

Dictionary

This FSelector can be instantiated with the associated sugar function fs():

fs("exhaustive_search")

Control Parameters

max_features

integer(1)
Maximum number of features. By default, number of features in mlr3::Task.

Super class

mlr3fselect::FSelector -> FSelectorExhaustiveSearch

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method clone()

The objects of this class are cloneable with this method.

Usage

FSelectorExhaustiveSearch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Feature Selection
# \donttest{

# retrieve task and load learner
task = tsk("penguins")
learner = lrn("classif.rpart")

# run feature selection on the Palmer Penguins data set
instance = fselect(
  fselector = fs("exhaustive_search"),
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  term_evals = 10
)

# best performing feature set
instance$result
#>    bill_depth bill_length body_mass flipper_length island   sex  year
#> 1:       TRUE        TRUE     FALSE          FALSE  FALSE FALSE FALSE
#>                  features classif.ce
#> 1: bill_depth,bill_length  0.1217391

# all evaluated feature sets
as.data.table(instance$archive)
#>     bill_depth bill_length body_mass flipper_length island   sex  year
#>  1:       TRUE       FALSE     FALSE          FALSE  FALSE FALSE FALSE
#>  2:      FALSE        TRUE     FALSE          FALSE  FALSE FALSE FALSE
#>  3:      FALSE       FALSE      TRUE          FALSE  FALSE FALSE FALSE
#>  4:      FALSE       FALSE     FALSE           TRUE  FALSE FALSE FALSE
#>  5:      FALSE       FALSE     FALSE          FALSE   TRUE FALSE FALSE
#>  6:      FALSE       FALSE     FALSE          FALSE  FALSE  TRUE FALSE
#>  7:      FALSE       FALSE     FALSE          FALSE  FALSE FALSE  TRUE
#>  8:       TRUE        TRUE     FALSE          FALSE  FALSE FALSE FALSE
#>  9:       TRUE       FALSE      TRUE          FALSE  FALSE FALSE FALSE
#> 10:       TRUE       FALSE     FALSE           TRUE  FALSE FALSE FALSE
#>     classif.ce runtime_learners           timestamp batch_nr warnings errors
#>  1:  0.2260870            0.005 2023-11-17 12:02:35        1        0      0
#>  2:  0.2521739            0.005 2023-11-17 12:02:35        1        0      0
#>  3:  0.2347826            0.004 2023-11-17 12:02:35        1        0      0
#>  4:  0.1478261            0.005 2023-11-17 12:02:35        1        0      0
#>  5:  0.2869565            0.005 2023-11-17 12:02:35        1        0      0
#>  6:  0.4956522            0.017 2023-11-17 12:02:35        1        0      0
#>  7:  0.5652174            0.004 2023-11-17 12:02:35        1        0      0
#>  8:  0.1217391            0.005 2023-11-17 12:02:35        1        0      0
#>  9:  0.2347826            0.005 2023-11-17 12:02:35        1        0      0
#> 10:  0.2260870            0.005 2023-11-17 12:02:35        1        0      0
#>                      features      resample_result
#>  1:                bill_depth <ResampleResult[21]>
#>  2:               bill_length <ResampleResult[21]>
#>  3:                 body_mass <ResampleResult[21]>
#>  4:            flipper_length <ResampleResult[21]>
#>  5:                    island <ResampleResult[21]>
#>  6:                       sex <ResampleResult[21]>
#>  7:                      year <ResampleResult[21]>
#>  8:    bill_depth,bill_length <ResampleResult[21]>
#>  9:      bill_depth,body_mass <ResampleResult[21]>
#> 10: bill_depth,flipper_length <ResampleResult[21]>

# subset the task and fit the final model
task$select(instance$result_feature_set)
learner$train(task)
# }