Feature Selection Filter

Feature Filters quantify the importance of each feature of a Task by assigning them a numerical score. In a second step, features can be selected by either selecting a fixed absolute or relative frequency of the best features, or by thresholding on the score value.

The Filter PipeOp allows to use filters as a preprocessing step.

Example Usage

Use the \(-\log_{10}()\)-transformed \(p\)-values of a Kruskal-Wallis rank sum test (implemented in kruskal.test()) for filtering features of the Diabetes tasks.

library("mlr3verse")
Loading required package: mlr3
# retrieve a task
task = tsk("diabetes")

# retrieve a filter
filter = flt("kruskal_test")

# calculate scores
filter$calculate(task)

# access scores
filter$scores
   glucose   pedigree   pressure        age   pregnant       mass    triceps 
5.28933204 0.66401067 0.42175611 0.27227545 0.20894196 0.16684113 0.07396207 
   insulin 
0.03614751 
# plot scores
autoplot(filter)

# subset task to 3 most important features
task$select(head(names(filter$scores), 3))
task$feature_names
[1] "glucose"  "pedigree" "pressure"