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 ($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 instance$assign_result(). ## Super classes bbotk::OptimInstance -> bbotk::OptimInstanceSingleCrit -> FSelectInstanceSingleCrit ## Active bindings result_feature_set (character()) Feature set for task subsetting. ## Methods ### Public methods Inherited methods ### Method new() Creates a new instance of this R6 class. #### Usage FSelectInstanceSingleCrit$new(
learner,
resampling,
measure,
terminator,
store_models = FALSE,
check_values = TRUE,
store_benchmark_result = TRUE
)

#### Arguments

task

learner
resampling

(mlr3::Resampling)
Uninstantiated resamplings are instantiated during construction so that all configurations are evaluated on the same data splits.

measure

(mlr3::Measure)
Measure to optimize.

terminator
store_models

(logical(1)). Store models in benchmark result?

check_values

(logical(1))
Check the parameters before the evaluation and the results for validity?

store_benchmark_result

(logical(1))
Store benchmark result in archive?

### Method assign_result()

The FSelector writes the best found feature subset and estimated performance value here. For internal use.

#### Arguments

deep

Whether to make a deep clone.

## Examples

library(mlr3)
library(data.table)

# Objects required to define the objective function
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.06000000
#> 2:        FALSE        TRUE        FALSE        TRUE 0.04666667
#>    runtime_learners           timestamp batch_nr      resample_result
#> 1:            0.810 2022-08-25 10:40:14        1 <ResampleResult[21]>
#> 2:            0.622 2022-08-25 10:40:14        1 <ResampleResult[21]>