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.
Abstract base method. Implement to specify feature selection of your subclass. See technical details sections.
Abstract base method. Implement to specify how the final feature subset is selected. See technical details sections.
A subclass is implemented in the following way:
Specify the private abstract method
$.optimize() and use it to call into
You need to call
instance$eval_batch() to evaluate feature subsets.
The batch evaluation is requested at the FSelectInstanceSingleCrit /
instance, so each batch is possibly
executed in parallel via
mlr3::benchmark(), and all evaluations are stored
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
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.
Creates a new instance of this R6 class.
FSelector$new(param_set, properties, packages = character(0))
Set of control parameters for fselector.
Set of properties of the fselector. Must be a subset of
Set of required packages. Note that these packages will be loaded via
requireNamespace(), and are not attached.
Helper for print outputs.
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.
The objects of this class are cloneable with this method.
FSelector$clone(deep = FALSE)
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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") # modifies the instance by reference fselector$optimize(instance) # returns best feature subset and best performance instance$result # allows access of data.table / benchmark result of full path of all evaluations instance$archive
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.