Skip to contents

Genetic search imitates the process of natural selection to generate feature sets.

Calls genalg::rbga.bin() from package genalg.

Dictionary

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

mlr_fselectors$get("genetic_search")
fs("genetic_search")

Parameters

suggestions

list()

popSize

integer(1)

mutationChance

numeric(1)

elitism

integer(1)

zeroToOneRatio

integer(1)

iters

integer(1)

For the meaning of the control parameters, see genalg::rbga.bin(). genalg::rbga.bin() internally terminates after iters iteration. We set ìters = 100000 to allow the termination via our terminators. If more iterations are needed, set ìters to a higher value in the parameter set.

Super class

mlr3fselect::FSelector -> FSelectorGeneticSearch

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

FSelectorGeneticSearch$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# retrieve task
task = tsk("pima")

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

# \donttest{
# feature selection on the pima indians diabetes data set
instance = fselect(
  method = "genetic_search",
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  term_evals = 10
)

# best performing feature subset
instance$result
#>      age glucose insulin  mass pedigree pregnant pressure triceps features
#> 1: FALSE    TRUE   FALSE FALSE    FALSE    FALSE    FALSE   FALSE  glucose
#>    classif.ce
#> 1:  0.2734375

# all evaluated feature subsets
as.data.table(instance$archive)
#>       age glucose insulin  mass pedigree pregnant pressure triceps classif.ce
#>  1: FALSE   FALSE   FALSE FALSE    FALSE     TRUE     TRUE   FALSE  0.3984375
#>  2: FALSE   FALSE    TRUE FALSE    FALSE    FALSE    FALSE   FALSE  0.3828125
#>  3: FALSE    TRUE   FALSE FALSE    FALSE    FALSE    FALSE   FALSE  0.2734375
#>  4: FALSE    TRUE   FALSE FALSE    FALSE    FALSE    FALSE   FALSE  0.2734375
#>  5: FALSE   FALSE   FALSE FALSE     TRUE    FALSE    FALSE   FALSE  0.3867188
#>  6: FALSE   FALSE   FALSE FALSE     TRUE    FALSE    FALSE   FALSE  0.3867188
#>  7: FALSE    TRUE   FALSE FALSE    FALSE    FALSE    FALSE   FALSE  0.2734375
#>  8: FALSE   FALSE    TRUE FALSE    FALSE    FALSE    FALSE   FALSE  0.3828125
#>  9: FALSE   FALSE   FALSE FALSE    FALSE     TRUE    FALSE   FALSE  0.3984375
#> 10: FALSE    TRUE   FALSE FALSE    FALSE    FALSE    FALSE   FALSE  0.2734375
#>     runtime_learners           timestamp batch_nr      resample_result
#>  1:            0.089 2022-08-25 10:40:34        1 <ResampleResult[21]>
#>  2:            0.090 2022-08-25 10:40:34        2 <ResampleResult[21]>
#>  3:            0.098 2022-08-25 10:40:35        3 <ResampleResult[21]>
#>  4:            0.090 2022-08-25 10:40:35        4 <ResampleResult[21]>
#>  5:            0.079 2022-08-25 10:40:35        5 <ResampleResult[21]>
#>  6:            0.072 2022-08-25 10:40:35        6 <ResampleResult[21]>
#>  7:            0.068 2022-08-25 10:40:36        7 <ResampleResult[21]>
#>  8:            0.070 2022-08-25 10:40:36        8 <ResampleResult[21]>
#>  9:            0.082 2022-08-25 10:40:36        9 <ResampleResult[21]>
#> 10:            0.080 2022-08-25 10:40:36       10 <ResampleResult[21]>

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