Removes features from Task depending on a Selector function: The selector parameter gives the features to keep. See Selector for selectors that are provided and how to write custom Selectors.

Format

R6Class object inheriting from PipeOpTaskPreprocSimple/PipeOpTaskPreproc/PipeOp.

Construction

PipeOpSelect$new(id = "select", param_vals = list())
  • id :: character(1)
    Identifier of resulting object, default "select".

  • param_vals :: named list
    List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction. Default list().

Input and Output Channels

Input and output channels are inherited from PipeOpTaskPreproc.

The output is the input Task with features removed that were not selected by the Selector/function in selector.

State

The $state is a named list with the $state elements inherited from PipeOpTaskPreproc, as well as:

  • selection :: character
    A vector of all feature names that are kept (i.e. not dropped) in the Task. Initialized to selector_all()

Parameters

Internals

Uses task$select().

Fields

Only fields inherited from PipeOpTaskPreproc/PipeOp.

Methods

Only methods inherited from PipeOpTaskPreprocSimple/PipeOpTaskPreproc/PipeOp.

See also

Examples

library("mlr3") task = tsk("boston_housing") pos = po("select") pos$param_set$values$selector = selector_all() pos$train(list(task))[[1]]$feature_names
#> [1] "age" "b" "chas" "cmedv" "crim" "dis" "indus" #> [8] "lat" "lon" "lstat" "nox" "ptratio" "rad" "rm" #> [15] "tax" "town" "tract" "zn"
pos$param_set$values$selector = selector_type("factor") pos$train(list(task))[[1]]$feature_names
#> [1] "chas" "town"
pos$param_set$values$selector = selector_invert(selector_type("factor")) pos$train(list(task))[[1]]$feature_names
#> [1] "age" "b" "cmedv" "crim" "dis" "indus" "lat" #> [8] "lon" "lstat" "nox" "ptratio" "rad" "rm" "tax" #> [15] "tract" "zn"
pos$param_set$values$selector = selector_grep("^r") pos$train(list(task))[[1]]$feature_names
#> [1] "rad" "rm"