• add_recipe() specifies the terms of the model and any preprocessing that is required through the usage of a recipe.

  • remove_recipe() removes the recipe as well as any downstream objects that might get created after the recipe is used for preprocessing, such as the prepped recipe. Additionally, if the model has already been fit, then the fit is removed.

  • update_recipe() first removes the recipe, then replaces the previous recipe with the new one. Any model that has already been fit based on this recipe will need to be refit.

add_recipe(x, recipe, ..., blueprint = NULL)

remove_recipe(x)

update_recipe(x, recipe, ..., blueprint = NULL)

Arguments

x

A workflow

recipe

A recipe created using recipes::recipe()

...

Not used.

blueprint

A hardhat blueprint used for fine tuning the preprocessing. If NULL, hardhat::default_recipe_blueprint() is used.

Value

x, updated with either a new or removed recipe preprocessor.

Details

To fit a workflow, one of add_formula() or add_recipe() must be specified, but not both.

Examples

library(recipes)
#> Loading required package: dplyr
#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
#> #> Attaching package: ‘recipes’
#> The following object is masked from ‘package:stats’: #> #> step
recipe <- recipe(mpg ~ cyl, mtcars) recipe <- step_log(recipe, cyl) workflow <- workflow() workflow <- add_recipe(workflow, recipe) workflow
#> ══ Workflow ════════════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ──────────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> ● step_log()
remove_recipe(workflow)
#> ══ Workflow ════════════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None
update_recipe(workflow, recipe(mpg ~ cyl, mtcars))
#> ══ Workflow ════════════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ──────────────────────────────────────────────────────────────── #> 0 Recipe Steps