Information gain filter calling
FSelectorRcpp::information_gain()
in package FSelectorRcpp. Set
parameter "type"
to "gainratio"
to calculate the gain ratio, or set to
"symuncert"
to calculate the symmetrical uncertainty (see
FSelectorRcpp::information_gain()
). Default is "infogain"
.
Argument equal
defaults to FALSE
for classification tasks, and to
TRUE
for regression tasks.
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_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 class
mlr3filters::Filter
-> FilterInformationGain
Examples
if (requireNamespace("FSelectorRcpp")) {
## InfoGain (default)
task = mlr3::tsk("sonar")
filter = flt("information_gain")
filter$calculate(task)
head(filter$scores, 3)
as.data.table(filter)
## GainRatio
filterGR = flt("information_gain")
filterGR$param_set$values = list("type" = "gainratio")
filterGR$calculate(task)
head(as.data.table(filterGR), 3)
}
#> feature score
#> <char> <num>
#> 1: V11 0.2053399
#> 2: V12 0.1802854
#> 3: V9 0.1633805
if (mlr3misc::require_namespaces(c("mlr3pipelines", "FSelectorRcpp", "rpart"), quietly = TRUE)) {
library("mlr3pipelines")
task = mlr3::tsk("spam")
# Note: `filter.frac` is selected randomly and should be tuned.
graph = po("filter", filter = flt("information_gain"), filter.frac = 0.5) %>>%
po("learner", mlr3::lrn("classif.rpart"))
graph$train(task)
}
#> $classif.rpart.output
#> NULL
#>