Skip to contents

Filter which uses the predictive performance of a mlr3::Learner as filter score. Performs a mlr3::resample() for each feature separately. The filter score is the aggregated performance of the mlr3::Measure, or the negated aggregated performance if the measure has to be minimized.

Super classes

mlr3filters::Filter -> mlr3filters::FilterLearner -> FilterPerformance

Public fields

learner

(mlr3::Learner)

resampling

(mlr3::Resampling)

measure

(mlr3::Measure)

Methods

Inherited methods


Method new()

Create a FilterDISR object.

Usage

FilterPerformance$new(
  learner = mlr3::lrn("classif.featureless"),
  resampling = mlr3::rsmp("holdout"),
  measure = NULL
)

Arguments

learner

(mlr3::Learner)
mlr3::Learner to use for model fitting.

resampling

(mlr3::Resampling)
mlr3::Resampling to be used within resampling.

measure

(mlr3::Measure)
mlr3::Measure to be used for evaluating the performance.


Method clone()

The objects of this class are cloneable with this method.

Usage

FilterPerformance$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (requireNamespace("rpart")) {
  task = mlr3::tsk("iris")
  learner = mlr3::lrn("classif.rpart")
  filter = flt("performance", learner = learner)
  filter$calculate(task)
  as.data.table(filter)
}
#>         feature score
#>          <char> <num>
#> 1:  Petal.Width  0.00
#> 2: Petal.Length -0.08
#> 3: Sepal.Length -0.28
#> 4:  Sepal.Width -0.44

if (mlr3misc::require_namespaces(c("mlr3pipelines", "rpart"), quietly = TRUE)) {
  library("mlr3pipelines")
  task = mlr3::tsk("iris")
  l = lrn("classif.rpart")

  # Note: `filter.frac` is selected randomly and should be tuned.

  graph = po("filter", filter = flt("performance", learner = l), filter.frac = 0.5) %>>%
    po("learner", mlr3::lrn("classif.rpart"))

  graph$train(task)
}
#> $classif.rpart.output
#> NULL
#>