Specifies a general feature selection scenario, including objective function
and archive for feature selection algorithms to act upon. This class stores
an ObjectiveFSelect object that encodes the black box objective function
which an FSelector has to optimize. It allows the basic operations of
querying the objective at feature subsets (
$eval_batch()), storing the
evaluations in the internal bbotk::Archive and accessing the final result
Evaluations of feature subsets are performed in batches by calling
mlr3::benchmark() internally. Before a batch is evaluated, the
bbotk::Terminator is queried for the remaining budget. If the available
budget is exhausted, an exception is raised, and no further evaluations can
be performed from this point on.
The FSelector is also supposed to store its final result, consisting
of a selected feature subset and associated estimated performance values, by
calling the method
Feature set for task subsetting.
Creates a new instance of this R6 class.
FSelectInstanceSingleCrit$new( task, learner, resampling, measure, terminator, store_models = FALSE, check_values = TRUE, store_benchmark_result = TRUE )
Task to operate on.
Uninstantiated resamplings are instantiated during construction so that all configurations are evaluated on the same data splits.
Measure to optimize.
Store models in benchmark result?
Check the parameters before the evaluation and the results for validity?
Store benchmark result in archive?
The FSelector writes the best found feature subset and estimated performance value here. For internal use.
The objects of this class are cloneable with this method.
FSelectInstanceSingleCrit$clone(deep = FALSE)
Whether to make a deep clone.
library(mlr3) library(data.table) # Objects required to define the objective function task = tsk("iris") measure = msr("classif.ce") learner = lrn("classif.rpart") resampling = rsmp("cv") # Create instance terminator = trm("evals", n_evals = 8) inst = FSelectInstanceSingleCrit$new( task = task, learner = learner, resampling = resampling, measure = measure, terminator = terminator ) # Try some feature subsets xdt = data.table( Petal.Length = c(TRUE, FALSE), Petal.Width = c(FALSE, TRUE), Sepal.Length = c(TRUE, FALSE), Sepal.Width = c(FALSE, TRUE) ) inst$eval_batch(xdt) # Get archive data as.data.table(inst$archive)#> Petal.Length Petal.Width Sepal.Length Sepal.Width classif.ce #> 1: TRUE FALSE TRUE FALSE 0.06666667 #> 2: FALSE TRUE FALSE TRUE 0.04666667 #> uhash timestamp batch_nr #> 1: acd96a66-041b-4351-8fa2-d1c9ff6e2cee 2021-01-18 04:56:24 1 #> 2: 7b550f95-5eca-4d23-9a96-e73f736ae2c7 2021-01-18 04:56:24 1 #> x_domain_Petal.Length x_domain_Petal.Width x_domain_Sepal.Length #> 1: TRUE FALSE TRUE #> 2: FALSE TRUE FALSE #> x_domain_Sepal.Width #> 1: FALSE #> 2: TRUE