`step_select_mrmr` creates a *specification* of a recipe step that will apply minimum Redundancy Maximum Relevance Feature Selection (mRMR) to numeric data. The top `top_p` scoring features, or features whose scores occur in the top percentile `threshold` will be retained as new predictors.

step_select_mrmr(
  recipe,
  ...,
  outcome = NULL,
  role = NA,
  trained = FALSE,
  top_p = NA,
  threshold = NA,
  threads = 0,
  exclude = NULL,
  scores = NULL,
  skip = FALSE,
  id = recipes::rand_id("select_mrmr")
)

# S3 method for step_select_mrmr
tidy(x, ...)

Arguments

recipe

A recipe object. The step will be added to the sequence of operations for this recipe

...

One or more selector functions to choose which variables are affected by the step. See selections() for more details. For the tidy method, these are not currently used

outcome

A character string specifying the name of response variable used to evaluate mRMR.

role

Not used by this step since no new variables are created

trained

A logical to indicate if the quantities for preprocessing have been estimated

top_p

An integer that will be used to select the number of best scoring features.

threshold

A numeric value between 0 and 1 representing the percentile of best scoring features to select. Features with scores that are _larger_ than the specified threshold will be retained, for example `threshold = 0.9` will retain only predictors with scores in the top 90th percentile. Note that this overrides `top_p`.

threads

An integer specifying the number of threads to use for processing. The default = 0 uses all available threads.

exclude

A character vector of predictor names that will be removed from the data. This will be set when `prep()` is used on the recipe and should not be set by the user.

scores

A tibble with 'variable' and 'scores' columns containing the names of the variables and their mRMR scores. This parameter is only produced after the recipe has been trained.

skip

A logical. Should the step be skipped when the recipe is baked by bake.recipe()? While all operations are baked when prep.recipe() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations.

id

A character string that is unique to this step to identify it.

x

A `step_select_mrmr` object.

Value

A step_select_mrmr object.

Details

The recipe will stop if both `top_p` and `threshold` are left unspecified.

Examples

library(recipes)

data(cells, package = "modeldata")

rec <-
 recipe(class ~ ., data = cells[, -1]) %>%
 step_select_mrmr(all_predictors(), outcome = "class", top_p = 10, threshold = 0.9)

prepped <- prep(rec)

new_data <- juice(prepped)
prepped
#> Recipe
#> 
#> Inputs:
#> 
#>       role #variables
#>    outcome          1
#>  predictor         56
#> 
#> Training data contained 2019 data points and no missing data.
#> 
#> Operations:
#> 
#> mRMR feature selection (50 excluded)