`step_select_carscore` creates a *specification* of a recipe step that selects a subset of predictors as part of a regression model based on the scores of the CAR score algorithm. This step requires the `care` package to be installed. The top `top_p` scoring features, or features whose scores occur in the top percentile `threshold` will be retained as new predictors.
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.
A character string with the name of the response variable. This must refer to a numeric feature for regression.
Not used by this step since no new variables are created.
A logical to indicate if the quantities for preprocessing have been estimated.
An integer with the number of best scoring features to select.
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`.
The correlation shrinkage intensity (range 0-1).
For diagonal = FALSE (the default) CAR scores are computed; otherwise with diagonal = TRUE marginal correlations.
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 tibble with 'variable' and 'scores' columns containing the names of the variables and the absolute values of the calculated CAR scores. This parameter is only produced after the recipe has been trained.
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_carscore` object.
A step_select_carscore object.
The recipe will stop if both `top_p` and `threshold` are left unspecified.
library(recipes)
data(car_prices, package = "modeldata")
rec <-
recipe(Price ~ ., data = car_prices) %>%
step_select_carscore(all_predictors(), outcome = "Price", top_p = 5, threshold = 0.7)
#> 1 package is needed for this step and is not installed. (care). Start a clean R session then run: install.packages("care")
prepped <- prep(rec)
#> Error in loadNamespace(x): there is no package called ‘care’
new_data <- juice(prepped)
#> Error in fully_trained(object): object 'prepped' not found
prepped
#> Error in eval(expr, envir, enclos): object 'prepped' not found