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: 8583480e-0428-4a20-88de-eb1859f5641f 2021-03-21 04:30:28 1 #> 2: 89f0f549-87dd-4135-9b14-6e29e10d0d8b 2021-03-21 04:30:28 1