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(
  method = "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.05217391

# 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
#> 11:       TRUE       FALSE     FALSE          FALSE   TRUE FALSE FALSE
#> 12:       TRUE       FALSE     FALSE          FALSE  FALSE  TRUE FALSE
#> 13:       TRUE       FALSE     FALSE          FALSE  FALSE FALSE  TRUE
#> 14:      FALSE        TRUE      TRUE          FALSE  FALSE FALSE FALSE
#> 15:      FALSE        TRUE     FALSE           TRUE  FALSE FALSE FALSE
#> 16:      FALSE        TRUE     FALSE          FALSE   TRUE FALSE FALSE
#> 17:      FALSE        TRUE     FALSE          FALSE  FALSE  TRUE FALSE
#> 18:      FALSE        TRUE     FALSE          FALSE  FALSE FALSE  TRUE
#> 19:      FALSE       FALSE      TRUE           TRUE  FALSE FALSE FALSE
#> 20:      FALSE       FALSE      TRUE          FALSE   TRUE FALSE FALSE
#> 21:      FALSE       FALSE      TRUE          FALSE  FALSE  TRUE FALSE
#> 22:      FALSE       FALSE      TRUE          FALSE  FALSE FALSE  TRUE
#> 23:      FALSE       FALSE     FALSE           TRUE   TRUE FALSE FALSE
#> 24:      FALSE       FALSE     FALSE           TRUE  FALSE  TRUE FALSE
#> 25:      FALSE       FALSE     FALSE           TRUE  FALSE FALSE  TRUE
#> 26:      FALSE       FALSE     FALSE          FALSE   TRUE  TRUE FALSE
#> 27:      FALSE       FALSE     FALSE          FALSE   TRUE FALSE  TRUE
#> 28:      FALSE       FALSE     FALSE          FALSE  FALSE  TRUE  TRUE
#>     bill_depth bill_length body_mass flipper_length island   sex  year
#>     classif.ce runtime_learners           timestamp batch_nr warnings errors
#>  1: 0.20869565            0.058 2022-11-25 12:09:43        1        0      0
#>  2: 0.24347826            0.059 2022-11-25 12:09:43        1        0      0
#>  3: 0.25217391            0.079 2022-11-25 12:09:43        1        0      0
#>  4: 0.19130435            0.061 2022-11-25 12:09:43        1        0      0
#>  5: 0.33913043            0.059 2022-11-25 12:09:43        1        0      0
#>  6: 0.49565217            0.060 2022-11-25 12:09:43        1        0      0
#>  7: 0.49565217            0.080 2022-11-25 12:09:43        1        0      0
#>  8: 0.05217391            0.085 2022-11-25 12:09:47        2        0      0
#>  9: 0.18260870            0.069 2022-11-25 12:09:47        2        0      0
#> 10: 0.24347826            0.057 2022-11-25 12:09:47        2        0      0
#> 11: 0.19130435            0.058 2022-11-25 12:09:47        2        0      0
#> 12: 0.20869565            0.060 2022-11-25 12:09:47        2        0      0
#> 13: 0.20869565            0.095 2022-11-25 12:09:47        2        0      0
#> 14: 0.08695652            0.057 2022-11-25 12:09:47        2        0      0
#> 15: 0.05217391            0.058 2022-11-25 12:09:47        2        0      0
#> 16: 0.05217391            0.060 2022-11-25 12:09:47        2        0      0
#> 17: 0.26956522            0.091 2022-11-25 12:09:47        2        0      0
#> 18: 0.25217391            0.060 2022-11-25 12:09:47        2        0      0
#> 19: 0.18260870            0.059 2022-11-25 12:09:47        2        0      0
#> 20: 0.23478261            0.060 2022-11-25 12:09:47        2        0      0
#> 21: 0.20869565            0.086 2022-11-25 12:09:47        2        0      0
#> 22: 0.25217391            0.066 2022-11-25 12:09:47        2        0      0
#> 23: 0.12173913            0.058 2022-11-25 12:09:47        2        0      0
#> 24: 0.19130435            0.059 2022-11-25 12:09:47        2        0      0
#> 25: 0.19130435            0.079 2022-11-25 12:09:47        2        0      0
#> 26: 0.33913043            0.077 2022-11-25 12:09:47        2        0      0
#> 27: 0.33913043            0.062 2022-11-25 12:09:47        2        0      0
#> 28: 0.55652174            0.062 2022-11-25 12:09:47        2        0      0
#>     classif.ce runtime_learners           timestamp batch_nr warnings errors
#>          resample_result
#>  1: <ResampleResult[21]>
#>  2: <ResampleResult[21]>
#>  3: <ResampleResult[21]>
#>  4: <ResampleResult[21]>
#>  5: <ResampleResult[21]>
#>  6: <ResampleResult[21]>
#>  7: <ResampleResult[21]>
#>  8: <ResampleResult[21]>
#>  9: <ResampleResult[21]>
#> 10: <ResampleResult[21]>
#> 11: <ResampleResult[21]>
#> 12: <ResampleResult[21]>
#> 13: <ResampleResult[21]>
#> 14: <ResampleResult[21]>
#> 15: <ResampleResult[21]>
#> 16: <ResampleResult[21]>
#> 17: <ResampleResult[21]>
#> 18: <ResampleResult[21]>
#> 19: <ResampleResult[21]>
#> 20: <ResampleResult[21]>
#> 21: <ResampleResult[21]>
#> 22: <ResampleResult[21]>
#> 23: <ResampleResult[21]>
#> 24: <ResampleResult[21]>
#> 25: <ResampleResult[21]>
#> 26: <ResampleResult[21]>
#> 27: <ResampleResult[21]>
#> 28: <ResampleResult[21]>
#>          resample_result

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