Filter for Embedded Feature Selection via Variable Importance
Source:R/FilterImportance.R
mlr_filters_importance.Rd
Variable Importance filter using embedded feature selection of machine learning algorithms. Takes a mlr3::Learner which is capable of extracting the variable importance (property "importance"), fits the model and extracts the importance values to use as filter scores.
See also
PipeOpFilter for filter-based feature selection.
Other Filter:
Filter
,
mlr_filters
,
mlr_filters_anova
,
mlr_filters_auc
,
mlr_filters_boruta
,
mlr_filters_carscore
,
mlr_filters_carsurvscore
,
mlr_filters_cmim
,
mlr_filters_correlation
,
mlr_filters_disr
,
mlr_filters_find_correlation
,
mlr_filters_information_gain
,
mlr_filters_jmi
,
mlr_filters_jmim
,
mlr_filters_kruskal_test
,
mlr_filters_mim
,
mlr_filters_mrmr
,
mlr_filters_njmim
,
mlr_filters_performance
,
mlr_filters_permutation
,
mlr_filters_relief
,
mlr_filters_selected_features
,
mlr_filters_univariate_cox
,
mlr_filters_variance
Super classes
mlr3filters::Filter
-> mlr3filters::FilterLearner
-> FilterImportance
Public fields
learner
(mlr3::Learner)
Learner to extract the importance values from.
Methods
Method new()
Create a FilterImportance object.
Usage
FilterImportance$new(learner = mlr3::lrn("classif.featureless"))
Arguments
learner
(mlr3::Learner)
Learner to extract the importance values from.
Examples
if (requireNamespace("rpart")) {
task = mlr3::tsk("iris")
learner = mlr3::lrn("classif.rpart")
filter = flt("importance", learner = learner)
filter$calculate(task)
as.data.table(filter)
}
#> feature score
#> <char> <num>
#> 1: Petal.Width 88.96940
#> 2: Petal.Length 81.34496
#> 3: Sepal.Length 54.09606
#> 4: Sepal.Width 36.01309
if (mlr3misc::require_namespaces(c("mlr3pipelines", "rpart", "mlr3learners"), quietly = TRUE)) {
library("mlr3learners")
library("mlr3pipelines")
task = mlr3::tsk("sonar")
learner = mlr3::lrn("classif.rpart")
# Note: `filter.frac` is selected randomly and should be tuned.
graph = po("filter", filter = flt("importance", learner = learner), filter.frac = 0.5) %>>%
po("learner", mlr3::lrn("classif.log_reg"))
graph$train(task)
}
#> Loading required package: mlr3
#> $classif.log_reg.output
#> NULL
#>