`step_select_roc` creates a *specification* of a recipe step that will filter predictors using their relationship with the outcome as measured using a Receiver Operating Characteristic curve.
A recipe object. The step will be added to the sequence of operations for this recipe.
One or more selector functions to choose which predictors are affected by the step. See [selections()] for more details. For the `tidy` method, these are not currently used.
A single character string that specifies a single categorical variable to be used as the class.
For model terms created by this step, what analysis role should they be assigned?. By default, the function assumes that resulting distances will be used as predictors in a model.
A logical to indicate if the quantities for preprocessing have been estimated.
A numeric value, in AUC units, where predictors with ROC AUC values _larger_ than the threshold will be retained. A value of `NA` implies that this criterion will be ignored.
An integer that will be used to select the predictors with the largest ROC AUC values. A value of `NA` implies that this criterion will be ignored.
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.
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.
A character string that is unique to this step to identify it.
A `step_select_roc` object.
An updated version of `recipe` with the new step added to the sequence of existing steps (if any). For the `tidy` method, a tibble with a `terms` column for which predictors were removed.
The recipe will stop if both `top_p` and `threshold` are left unspecified.
The ROC AUC will be set to be 1 - AUC if the value is less than 0.50.
data(cells, package = "modeldata")
rec <-
recipe(class ~ ., data = cells[, -1]) %>%
step_select_roc(all_predictors(), outcome = "class", top_p = 10, threshold = 0.9) %>%
prep()
rec %>% juice(all_predictors()) %>% names()
#> [1] "avg_inten_ch_1" "avg_inten_ch_2"
#> [3] "convex_hull_area_ratio_ch_1" "convex_hull_perim_ratio_ch_1"
#> [5] "entropy_inten_ch_1" "fiber_width_ch_1"
#> [7] "shape_p_2_a_ch_1" "total_inten_ch_1"
#> [9] "total_inten_ch_2" "var_inten_ch_1"
# Use ROC values to select but always keep at least one:
rec <-
recipe(class ~ ., data = cells[, -1]) %>%
step_select_roc(all_predictors(), outcome = "class", top_p = 1, threshold = 0.99) %>%
prep()
rec %>% juice(all_predictors()) %>% names()
#> [1] "fiber_width_ch_1"
# in case of missing data...