Simple correlation filter calling stats::cor(). The filter score is the absolute value of the correlation.

See also

Super class

mlr3filters::Filter -> FilterCorrelation

Methods

Public methods

Inherited methods

Method new()

Create a FilterCorrelation object.

Usage

FilterCorrelation$new(
  id = "correlation",
  task_type = "regr",
  param_set = ParamSet$new(list(ParamFct$new("use", default = "everything", levels =
    c("everything", "all.obs", "complete.obs", "na.or.complete",
    "pairwise.complete.obs")), ParamFct$new("method", default = "pearson", levels =
    c("pearson", "kendall", "spearman")))),
  packages = "stats",
  feature_types = c("integer", "numeric")
)

Arguments

id

(character(1))
Identifier for the filter.

task_type

(character())
Types of the task the filter can operator on. E.g., "classif" or "regr".

param_set

(paradox::ParamSet)
Set of hyperparameters.

packages

(character())
Set of required packages. Note that these packages will be loaded via requireNamespace(), and are not attached.

feature_types

(character())
Feature types the filter operates on. Must be a subset of mlr_reflections$task_feature_types.


Method clone()

The objects of this class are cloneable with this method.

Usage

FilterCorrelation$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

## Pearson (default) task = mlr3::tsk("mtcars") filter = flt("correlation") filter$calculate(task) as.data.table(filter)
#> feature score #> 1: wt 0.8676594 #> 2: cyl 0.8521620 #> 3: disp 0.8475514 #> 4: hp 0.7761684 #> 5: drat 0.6811719 #> 6: vs 0.6640389 #> 7: am 0.5998324 #> 8: carb 0.5509251 #> 9: gear 0.4802848 #> 10: qsec 0.4186840
## Spearman filter = FilterCorrelation$new() filter$param_set$values = list("method" = "spearman") filter$calculate(task) as.data.table(filter)
#> feature score #> 1: cyl 0.9108013 #> 2: disp 0.9088824 #> 3: hp 0.8946646 #> 4: wt 0.8864220 #> 5: vs 0.7065968 #> 6: carb 0.6574976 #> 7: drat 0.6514555 #> 8: am 0.5620057 #> 9: gear 0.5427816 #> 10: qsec 0.4669358