The AutoFSelector is a mlr3::Learner which wraps another mlr3::Learner and performs the following steps during $train():

  1. The wrapped (inner) learner is trained on the feature subsets via resampling. The feature selection can be specified by providing a FSelector, a bbotk::Terminator, a mlr3::Resampling and a mlr3::Measure.

  2. A final model is fit on the complete training data with the best found feature subset.

During $predict() the AutoFSelector just calls the predict method of the wrapped (inner) learner.

Note that this approach allows to perform nested resampling by passing an AutoFSelector object to mlr3::resample() or mlr3::benchmark(). To access the inner resampling results, set store_fselect_instance = TRUE and execute mlr3::resample() or mlr3::benchmark() with store_models = TRUE.

Super class

mlr3::Learner -> AutoFSelector

Public fields

instance_args

(list())
All arguments from construction to create the FSelectInstanceSingleCrit.

fselector

(FSelector)
Stores the feature selection algorithm.

Active bindings

archive

([ArchiveFSelect)
Returns FSelectInstanceSingleCrit archive.

learner

(mlr3::Learner)
Trained learner.

fselect_instance

(FSelectInstanceSingleCrit)
Internally created feature selection instance with all intermediate results.

fselect_result

(named list())
Short-cut to $result from FSelectInstanceSingleCrit.

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage

AutoFSelector$new(
  learner,
  resampling,
  measure,
  terminator,
  fselector,
  store_fselect_instance = TRUE,
  store_benchmark_result = TRUE,
  store_models = FALSE,
  check_values = FALSE
)

Arguments

learner

(mlr3::Learner)
Learner to optimize the feature subset for, see FSelectInstanceSingleCrit.

resampling

(mlr3::Resampling)
Resampling strategy during feature selection, see FSelectInstanceSingleCrit. This mlr3::Resampling is meant to be the inner resampling, operating on the training set of an arbitrary outer resampling. For this reason it is not feasible to pass an instantiated mlr3::Resampling here.

measure

(mlr3::Measure)
Performance measure to optimize.

terminator

(bbotk::Terminator)
When to stop feature selection, see FSelectInstanceSingleCrit.

fselector

(FSelector)
Feature selection algorithm to run.

store_fselect_instance

(logical(1))
If TRUE (default), stores the internally created FSelectInstanceSingleCrit with all intermediate results in slot $fselect_instance.

store_benchmark_result

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

store_models

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

check_values

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


Method clone()

The objects of this class are cloneable with this method.

Usage

AutoFSelector$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3) task = tsk("iris") learner = lrn("classif.rpart") resampling = rsmp("holdout") measure = msr("classif.ce") terminator = trm("evals", n_evals = 3) fselector = fs("exhaustive_search") afs = AutoFSelector$new(learner, resampling, measure, terminator, fselector, store_fselect_instance = TRUE) afs$train(task) afs$model
#> $learner #> <LearnerClassifRpart:classif.rpart> #> * Model: rpart #> * Parameters: xval=0 #> * Packages: rpart #> * Predict Type: response #> * Feature types: logical, integer, numeric, factor, ordered #> * Properties: importance, missings, multiclass, selected_features, #> twoclass, weights #> #> $features #> [1] "Petal.Length" #> #> $fselect_instance #> <FSelectInstanceSingleCrit> #> * State: Optimized #> * Objective: <ObjectiveFSelect:classif.rpart_on_iris> #> * Search Space: #> <ParamSet> #> id class lower upper levels default value #> 1: Petal.Length ParamLgl NA NA TRUE,FALSE <NoDefault[3]> #> 2: Petal.Width ParamLgl NA NA TRUE,FALSE <NoDefault[3]> #> 3: Sepal.Length ParamLgl NA NA TRUE,FALSE <NoDefault[3]> #> 4: Sepal.Width ParamLgl NA NA TRUE,FALSE <NoDefault[3]> #> * Terminator: <TerminatorEvals> #> * Terminated: TRUE #> * Result: #> Petal.Length Petal.Width Sepal.Length Sepal.Width features x_domain #> 1: TRUE FALSE FALSE FALSE Petal.Length <list[4]> #> classif.ce #> 1: 0.06 #> * Archive: #> <ArchiveFSelect> #> Petal.Length Petal.Width Sepal.Length Sepal.Width classif.ce #> 1: TRUE FALSE FALSE FALSE 0.06 #> 2: FALSE TRUE FALSE FALSE 0.06 #> 3: FALSE FALSE TRUE FALSE 0.50 #> 4: FALSE FALSE FALSE TRUE 0.44 #> uhash x_domain timestamp batch_nr #> 1: f443353d-b649-45ef-a9e5-411fba0ec289 <list[4]> 2020-12-03 04:30:08 1 #> 2: 4e018335-9516-4119-8b8b-5a36df106d48 <list[4]> 2020-12-03 04:30:08 1 #> 3: 34ca6b2f-ad4e-47c6-90a1-e7831911abf0 <list[4]> 2020-12-03 04:30:08 1 #> 4: b9e8963f-4d21-44e9-b1ca-acc3185ec561 <list[4]> 2020-12-03 04:30:08 1 #>
afs$learner
#> <LearnerClassifRpart:classif.rpart> #> * Model: rpart #> * Parameters: xval=0 #> * Packages: rpart #> * Predict Type: response #> * Feature types: logical, integer, numeric, factor, ordered #> * Properties: importance, missings, multiclass, selected_features, #> twoclass, weights