Skip to contents

The FSelectInstanceBatchSingleCrit specifies a feature selection problem for a FSelector. The function fsi() creates a FSelectInstanceBatchSingleCrit and the function fselect() creates an instance internally.

The instance contains an ObjectiveFSelectBatch object that encodes the black box objective function a FSelector has to optimize. The instance allows the basic operations of querying the objective at design points ($eval_batch()). This operation is usually done by the FSelector. Evaluations of feature subsets are performed in batches by calling mlr3::benchmark() internally. The evaluated feature subsets are stored in the Archive ($archive). 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().

Default Measures

If no measure is passed, the default measure is used. The default measure depends on the task type.

TaskDefault MeasurePackage


There are several sections about feature selection in the mlr3book.

The gallery features a collection of case studies and demos about optimization.


For analyzing the feature selection results, it is recommended to pass the archive to The returned data table is joined with the benchmark result which adds the mlr3::ResampleResult for each feature set.

The archive provides various getters (e.g. $learners()) to ease the access. All getters extract by position (i) or unique hash (uhash). For a complete list of all getters see the methods section.

The benchmark result ($benchmark_result) allows to score the feature sets again on a different measure. Alternatively, measures can be supplied to

Super classes

bbotk::OptimInstance -> bbotk::OptimInstanceBatch -> bbotk::OptimInstanceBatchSingleCrit -> FSelectInstanceBatchSingleCrit

Active bindings


Feature set for task subsetting.


Inherited methods

Method new()

Creates a new instance of this R6 class.


  store_benchmark_result = TRUE,
  store_models = FALSE,
  check_values = FALSE,
  callbacks = NULL,
  ties_method = "least_features"



Task to operate on.


Learner to optimize the feature subset for.


Resampling that is used to evaluated the performance of the feature subsets. Uninstantiated resamplings are instantiated during construction so that all feature subsets are evaluated on the same data splits. Already instantiated resamplings are kept unchanged.


Measure to optimize. If NULL, default measure is used.


Stop criterion of the feature selection.


Store benchmark result in archive?


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


Check the parameters before the evaluation and the results for validity?


(list of CallbackBatchFSelect)
List of callbacks.


The method to break ties when selecting sets while optimizing and when selecting the best set. Can be "least_features" or "random". The option "least_features" (default) selects the feature set with the least features. If there are multiple best feature sets with the same number of features, one is selected randomly. The random method returns a random feature set from the best feature sets. Ignored if multiple measures are used.

Method assign_result()

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


FSelectInstanceBatchSingleCrit$assign_result(xdt, y)



x values as data.table. Each row is one point. Contains the value in the search space of the FSelectInstanceBatchMultiCrit object. Can contain additional columns for extra information.


Optimal outcome.

Method print()







Method clone()

The objects of this class are cloneable with this method.


FSelectInstanceBatchSingleCrit$clone(deep = FALSE)



Whether to make a deep clone.


# Feature selection on Palmer Penguins data set
# \donttest{

task = tsk("penguins")
learner = lrn("classif.rpart")

# Construct feature selection instance
instance = fsi(
  task = task,
  learner = learner,
  resampling = rsmp("cv", folds = 3),
  measures = msr("classif.ce"),
  terminator = trm("evals", n_evals = 4)

# Choose optimization algorithm
fselector = fs("random_search", batch_size = 2)

# Run feature selection
#>    bill_depth bill_length body_mass flipper_length island    sex   year
#>        <lgcl>      <lgcl>    <lgcl>         <lgcl> <lgcl> <lgcl> <lgcl>
#> 1:       TRUE        TRUE      TRUE           TRUE   TRUE   TRUE   TRUE
#>                                                          features n_features
#>                                                            <list>      <int>
#> 1: bill_depth,bill_length,body_mass,flipper_length,island,sex,...          7
#>    classif.ce
#>         <num>
#> 1: 0.04652937

# Subset task to optimal feature set

# Train the learner with optimal feature set on the full data set

# Inspect all evaluated sets$archive)
#>    bill_depth bill_length body_mass flipper_length island    sex   year
#>        <lgcl>      <lgcl>    <lgcl>         <lgcl> <lgcl> <lgcl> <lgcl>
#> 1:      FALSE        TRUE      TRUE          FALSE  FALSE  FALSE  FALSE
#> 2:       TRUE        TRUE      TRUE          FALSE   TRUE   TRUE   TRUE
#> 3:       TRUE        TRUE      TRUE           TRUE   TRUE   TRUE   TRUE
#> 4:       TRUE        TRUE      TRUE           TRUE   TRUE   TRUE   TRUE
#>    classif.ce runtime_learners           timestamp batch_nr warnings errors
#>         <num>            <num>              <POSc>    <int>    <int>  <int>
#> 1: 0.11929825            0.022 2024-06-30 09:39:29        1        0      0
#> 2: 0.06117468            0.028 2024-06-30 09:39:29        1        0      0
#> 3: 0.04652937            0.029 2024-06-30 09:39:29        2        0      0
#> 4: 0.04652937            0.028 2024-06-30 09:39:29        2        0      0
#>                                                          features n_features
#>                                                            <list>     <list>
#> 1:                                          bill_length,body_mass          2
#> 2:               bill_depth,bill_length,body_mass,island,sex,year          6
#> 3: bill_depth,bill_length,body_mass,flipper_length,island,sex,...          7
#> 4: bill_depth,bill_length,body_mass,flipper_length,island,sex,...          7
#>     resample_result
#>              <list>
#> 1: <ResampleResult>
#> 2: <ResampleResult>
#> 3: <ResampleResult>
#> 4: <ResampleResult>
# }