Skip to contents

`step_select_boruta` creates a *specification* of a recipe step that selects a subset of predictors using the Boruta feature selection approach.

Usage

step_select_boruta(
  recipe,
  ...,
  outcome = NULL,
  role = "predictor",
  trained = FALSE,
  exclude = NULL,
  options = list(pValue = 0.01, mcAdj = TRUE, maxRuns = 100),
  res = NULL,
  skip = FALSE,
  id = recipes::rand_id("select_boruta")
)

# S3 method for step_select_boruta
tidy(x, type = "terms", ...)

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 with the name of the response variable to use to calculate the feature importance scores.

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.

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.

options

A list of options to pass to `Boruta::Boruta()`. The defaults use Boruta's defaults. *Note* that `x` and `y` should not be passed here.

res

The `Boruta::Boruta` object is stored here once this preprocessing step has been trained by `prep.recipe()`.

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_boruta` object.

type

A character with either 'terms' (the default) to return a tibble containing the variables that have been removed by the filter step, or 'scores' to return the scores for each variable.

Value

a `step_select_boruta` object.

Details

The Boruta algorithm technically is a wrapper approach that uses random forests to test whether the feature importance scores obtained on the original data are higher than best of the scores obtained when the variables are randomly permuted. These permuted features are termed 'shadow' features. If the scores for any original feature are higher than the best of the scores for the randomly permuted features, then this is marked as a 'hit'. Features are confirmed or rejected based on a confidence threshold (default is p = 0.01) applied to the tails of the binomial distribution with p = 0.5. Features that do not fall within the lower (reject) or upper (accept) tails of the distribution are labelled as 'tentative'. Rejected features are dropped from the feature set and the procedure is repeated until no more 'tentative' features exist, or that a maximum number of runs are reached.

Examples

library(recipes)
library(parsnip)

# load the example iris dataset
data(cells, package = "modeldata")

# create a preprocessing recipe
rec <-
 recipe(class ~ ., data = cells[, -1]) %>%
 step_select_boruta(all_predictors(), outcome = "class")

prepped <- prep(rec)

preproc_data <- juice(prepped)
prepped
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs 
#> Number of variables by role
#> outcome:    1
#> predictor: 56
#> 
#> ── Training information 
#> Training data contained 2019 data points and no incomplete rows.
#> 
#> ── Operations 
#> Boruta feature selection (5 excluded)