Abstract FSelector class that implements the base functionality each fselector must provide. A FSelector object describes the feature selection strategy, i.e. how to optimize the black-box function and its feasible set defined by the FSelectInstanceSingleCrit / FSelectInstanceMultiCrit object.

A fselector must write its result into the FSelectInstanceSingleCrit / FSelectInstanceMultiCrit using the assign_result method of the bbotk::OptimInstance at the end of its selection in order to store the best selected feature subset and its estimated performance vector.

Private Methods

  • .optimize(instance) -> NULL
    Abstract base method. Implement to specify feature selection of your subclass. See technical details sections.

  • .assign_result(instance) -> NULL
    Abstract base method. Implement to specify how the final feature subset is selected. See technical details sections.

Technical Details and Subclasses

A subclass is implemented in the following way:

  • Inherit from FSelector.

  • Specify the private abstract method $.optimize() and use it to call into your optimizer.

  • You need to call instance$eval_batch() to evaluate feature subsets.

  • The batch evaluation is requested at the FSelectInstanceSingleCrit / FSelectInstanceMultiCrit object instance, so each batch is possibly executed in parallel via mlr3::benchmark(), and all evaluations are stored inside of instance$archive.

  • Before the batch evaluation, the bbotk::Terminator is checked, and if it is positive, an exception of class "terminated_error" is generated. In the later case the current batch of evaluations is still stored in instance, but the numeric scores are not sent back to the handling optimizer as it has lost execution control.

  • After such an exception was caught we select the best feature subset from instance$archive and return it.

  • Note that therefore more points than specified by the bbotk::Terminator may be evaluated, as the Terminator is only checked before a batch evaluation, and not in-between evaluation in a batch. How many more depends on the setting of the batch size.

  • Overwrite the private super-method .assign_result() if you want to decide yourself how to estimate the final feature subset in the instance and its estimated performance. The default behavior is: We pick the best resample-experiment, regarding the given measure, then assign its feature subset and aggregated performance to the instance.

Public fields

param_set

(paradox::ParamSet).

param_classes

(character()).

properties

(character()).

packages

(character()).

Methods

Public methods


Method new()

Creates a new instance of this R6 class.

Usage

FSelector$new(param_set, properties, packages = character(0))

Arguments

param_set

paradox::ParamSet
Set of control parameters for fselector.

properties

(character())
Set of properties of the fselector. Must be a subset of mlr_reflections$fselect_properties.

packages

(character())
Set of required packages. Note that these packages will be loaded via requireNamespace(), and are not attached.


Method format()

Helper for print outputs.

Usage

FSelector$format()

Returns

(character()).


Method print()

Print method.

Usage

FSelector$print()

Returns

(character()).


Method optimize()

Performs the feature selection on a FSelectInstanceSingleCrit or FSelectInstanceMultiCrit until termination. The single evaluations will be written into the ArchiveFSelect that resides in the FSelectInstanceSingleCrit / FSelectInstanceMultiCrit. The result will be written into the instance object.

Usage

FSelector$optimize(inst)

Arguments

Returns

data.table::data.table.


Method clone()

The objects of this class are cloneable with this method.

Usage

FSelector$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3) terminator = trm("evals", n_evals = 3) instance = FSelectInstanceSingleCrit$new( task = tsk("iris"), learner = lrn("classif.rpart"), resampling = rsmp("holdout"), measure = msr("classif.ce"), terminator = terminator ) # swap this line to use a different FSelector fselector = fs("random_search") # \donttest{ # modifies the instance by reference fselector$optimize(instance)
#> Petal.Length Petal.Width Sepal.Length Sepal.Width features #> 1: TRUE FALSE TRUE FALSE Petal.Length,Sepal.Length #> x_domain classif.ce #> 1: <list[4]> 0.02
# returns best feature subset and best performance instance$result
#> Petal.Length Petal.Width Sepal.Length Sepal.Width features #> 1: TRUE FALSE TRUE FALSE Petal.Length,Sepal.Length #> x_domain classif.ce #> 1: <list[4]> 0.02
# allows access of data.table / benchmark result of full path of all evaluations instance$archive# }
#> <ArchiveFSelect> #> Petal.Length Petal.Width Sepal.Length Sepal.Width classif.ce #> 1: TRUE FALSE TRUE FALSE 0.02 #> 2: TRUE TRUE TRUE TRUE 0.02 #> 3: TRUE TRUE TRUE TRUE 0.02 #> 4: FALSE FALSE TRUE FALSE 0.34 #> 5: TRUE TRUE TRUE TRUE 0.02 #> 6: TRUE TRUE FALSE FALSE 0.02 #> 7: TRUE TRUE TRUE TRUE 0.02 #> 8: FALSE FALSE TRUE FALSE 0.34 #> 9: TRUE FALSE FALSE FALSE 0.02 #> 10: TRUE TRUE TRUE FALSE 0.02 #> uhash x_domain timestamp batch_nr #> 1: 43ba0c67-1173-4ca5-97f8-6d862a5bb970 <list[4]> 2020-10-31 04:26:16 1 #> 2: 1596ba30-35b0-4f67-b2fc-d8180bbd7360 <list[4]> 2020-10-31 04:26:16 1 #> 3: 727d546f-556c-411e-a3df-33e620c400dd <list[4]> 2020-10-31 04:26:16 1 #> 4: f02ee97e-a1d2-47c1-b3eb-6ff28e0b0def <list[4]> 2020-10-31 04:26:16 1 #> 5: 241f9b07-57be-46f1-82a3-e5fb1804d037 <list[4]> 2020-10-31 04:26:16 1 #> 6: a1a0ca26-4faa-4e72-ae0d-ff28d80b5865 <list[4]> 2020-10-31 04:26:16 1 #> 7: 47d824d4-0b17-4d97-9c61-6e3218f530a0 <list[4]> 2020-10-31 04:26:16 1 #> 8: 96a6c4fc-5d79-41c7-ab9b-10abe4337b60 <list[4]> 2020-10-31 04:26:16 1 #> 9: 9eaa272b-889d-427a-8bc0-f1a140890577 <list[4]> 2020-10-31 04:26:16 1 #> 10: ade80326-0849-43fe-a759-0e8913c40f2b <list[4]> 2020-10-31 04:26:16 1