- 
                Notifications
    You must be signed in to change notification settings 
- Fork 121
Open
Labels
featurea feature request or enhancementa feature request or enhancement
Description
Feature
When testing multiple model types (e.g., in an ensemble workflow), one could create a baseline recipe that works for most of the models. Then if one model has slightly different pre-processing requirements (e.g., maybe you'd prefer to remove step_dummy in a rand_forest model or remove step_rm to include more predictors in an elastic net compared to a knn), a single call to this function could remove those steps and avoid the need to copy/paste the original recipe definition and delete certain steps. This helps to keep recipe definitions DRY.
Reproducible Example
FWIW, I chose the verb ignore_ to avoid confusion with 'remove' from step_rm.
Happy to submit a pull request if this seems valuable.
suppressPackageStartupMessages(devtools::load_all("."))
#> Loading recipes
rec <- recipe(Species ~ ., data = iris) %>%
  step_rm(Petal.Width, id = "rm_UDLut") %>%
  step_rm(starts_with("Sepal"), id = "custom_id")
rec %>% ignore_step("custom_id") # remove by custom id value
#> Recipe
#> 
#> Inputs:
#> 
#>       role #variables
#>    outcome          1
#>  predictor          4
#> 
#> Operations:
#> 
#> Variables removed Petal.Width
rec %>% ignore_step(1) # remove the first step
#> Recipe
#> 
#> Inputs:
#> 
#>       role #variables
#>    outcome          1
#>  predictor          4
#> 
#> Operations:
#> 
#> Variables removed starts_with("Sepal")
rec %>% ignore_step("rm") # remove all `step_rm` steps  (i.e., all steps here)
#> Recipe
#> 
#> Inputs:
#> 
#>       role #variables
#>    outcome          1
#>  predictor          4
#> 
#> Operations:Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement