mlr_filters_selected_features {mlr3filters} | R Documentation |
Filter for Embedded Feature Selection
Description
Filter using embedded feature selection of machine learning algorithms. Takes a mlr3::Learner which is capable of extracting the selected features (property "selected_features"), fits the model and extracts the selected features.
Note that contrary to mlr_filters_importance, there is no ordering in
the selected features. Selected features get a score of 1, deselected
features get a score of 0. The order of selected features is random and
different from the order in the learner. In combination with
mlr3pipelines, only the filter criterion cutoff
makes sense.
Super classes
mlr3filters::Filter
-> mlr3filters::FilterLearner
-> FilterSelectedFeatures
Public fields
learner
(mlr3::Learner)
Learner to extract the importance values from.
Methods
Public methods
Inherited methods
Method new()
Create a FilterImportance object.
Usage
FilterSelectedFeatures$new(learner = mlr3::lrn("classif.featureless"))
Arguments
learner
(mlr3::Learner)
Learner to extract the selected features from.
Method clone()
The objects of this class are cloneable with this method.
Usage
FilterSelectedFeatures$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
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_importance
,
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_univariate_cox
,
mlr_filters_variance
Examples
if (requireNamespace("rpart")) {
task = mlr3::tsk("iris")
learner = mlr3::lrn("classif.rpart")
filter = flt("selected_features", learner = learner)
filter$calculate(task)
as.data.table(filter)
}
if (mlr3misc::require_namespaces(c("mlr3pipelines", "mlr3learners", "rpart"), quietly = TRUE)) {
library("mlr3pipelines")
library("mlr3learners")
task = mlr3::tsk("sonar")
filter = flt("selected_features", learner = lrn("classif.rpart"))
# Note: All filter scores are either 0 or 1, i.e. setting `filter.cutoff = 0.5` means that
# we select all "selected features".
graph = po("filter", filter = filter, filter.cutoff = 0.5) %>>%
po("learner", mlr3::lrn("classif.log_reg"))
graph$train(task)
}