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: f8b7b280-8c49-49d1-a7ff-bf9a5c598d10 2021-05-06 04:33:16 1 #> 2: 49995abf-2d76-4442-8693-2f6d6f1dd43d 2021-05-06 04:33:16 1