`step_select_aov` creates a *specification* of a recipe step that will filter predictors using their relationship with a numerical outcome as measured using an ANOVA F-test.
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 predictors are affected by the step. See [selections()] for more details. For the `tidy` method, these are not currently used.
- outcome
A single character string that specifies a single numeric variable.
- role
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.
- trained
A logical to indicate if the quantities for preprocessing have been estimated.
- top_p
An integer that will be used to select the `top_p` predictors with the smallest p-values. A value of `NA` implies that this criterion will be ignored.
- threshold
A numeric value between 0 and 1 representing the percentile of best scoring features to select. For example `threshold = 0.9` will retain only predictors with scores in the top 90th percentile and a smaller threshold will select more features. Note that `top_p` and `threshold` are mutually exclusive but either can be used in conjunction with `cutoff` to select the top-ranked features and those that are smaller than the cutoff value.
- cutoff
A numeric value, in -log10(p-value) units, where predictors with _larger_ than the cutoff will be retained. A value of `NA` implies that this criterion will be ignored.
- 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.
- 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_aov` object.
Value
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.
Details
The recipe will stop if both `top_p`, `threshold` or `cutoff` are left unspecified. If both are used, they are combined via 'or'.
Examples
data(ames, package = "modeldata")
rec <-
recipe(Sale_Price ~ ., data = ames) %>%
step_select_aov(
all_nominal(),
-all_outcomes(),
outcome = "Sale_Price",
top_p = 1,
cutoff = -log10(0.01)
) %>%
prep()
rec %>%
juice(all_nominal()) %>%
names()
#> [1] "MS_SubClass" "MS_Zoning" "Lot_Shape" "Land_Contour"
#> [5] "Lot_Config" "Neighborhood" "Condition_1" "Condition_2"
#> [9] "Bldg_Type" "House_Style" "Overall_Cond" "Roof_Style"
#> [13] "Roof_Matl" "Exterior_1st" "Exterior_2nd" "Mas_Vnr_Type"
#> [17] "Foundation" "Bsmt_Cond" "Bsmt_Exposure" "BsmtFin_Type_1"
#> [21] "Heating" "Heating_QC" "Central_Air" "Functional"
#> [25] "Garage_Type" "Garage_Finish" "Pool_QC" "Sale_Type"
tidy(rec, number = 1)
#> # A tibble: 12 × 2
#> terms id
#> <chr> <chr>
#> 1 Alley select_aov_4lwhR
#> 2 Misc_Feature select_aov_4lwhR
#> 3 Garage_Cond select_aov_4lwhR
#> 4 Exter_Cond select_aov_4lwhR
#> 5 BsmtFin_Type_2 select_aov_4lwhR
#> 6 Utilities select_aov_4lwhR
#> 7 Land_Slope select_aov_4lwhR
#> 8 Paved_Drive select_aov_4lwhR
#> 9 Sale_Condition select_aov_4lwhR
#> 10 Electrical select_aov_4lwhR
#> 11 Fence select_aov_4lwhR
#> 12 Street select_aov_4lwhR