Skip to content

Workflows can take special arguments for the recipe (e.g. a blueprint) or a model (e.g. a special formula). However, when creating a workflow set, there is no way to specify these extra components.

update_workflow_model() and update_workflow_recipe() allow users to set these values after the workflow set is initially created. They are analogous to workflows::add_model() or workflows::add_recipe().

Usage

update_workflow_model(x, id, spec, formula = NULL)

update_workflow_recipe(x, id, recipe, blueprint = NULL)

Arguments

x

A workflow set.

id

A single character string from the wflow_id column indicating which workflow to update.

spec

A parsnip model specification.

formula

An optional formula override to specify the terms of the model. Typically, the terms are extracted from the formula or recipe preprocessing methods. However, some models (like survival and bayesian models) use the formula not to preprocess, but to specify the structure of the model. In those cases, a formula specifying the model structure must be passed unchanged into the model call itself. This argument is used for those purposes.

recipe

A recipe created using recipes::recipe()

blueprint

A hardhat blueprint used for fine tuning the preprocessing.

If NULL, hardhat::default_recipe_blueprint() is used.

Note that preprocessing done here is separate from preprocessing that might be done automatically by the underlying model.

Examples

library(parsnip)
new_mod <-
  decision_tree() %>%
  set_engine("rpart", method = "anova") %>%
  set_mode("classification")

new_set <- update_workflow_model(two_class_res, "none_cart", spec = new_mod)
new_set
#> # A workflow set/tibble: 6 × 4
#>   wflow_id      info             option    result    
#>   <chr>         <list>           <list>    <list>    
#> 1 none_cart     <tibble [1 × 4]> <opts[3]> <list [0]>
#> 2 none_glm      <tibble [1 × 4]> <opts[3]> <rsmp[+]> 
#> 3 none_mars     <tibble [1 × 4]> <opts[3]> <tune[+]> 
#> 4 yj_trans_cart <tibble [1 × 4]> <opts[3]> <tune[+]> 
#> 5 yj_trans_glm  <tibble [1 × 4]> <opts[3]> <rsmp[+]> 
#> 6 yj_trans_mars <tibble [1 × 4]> <opts[3]> <tune[+]> 

extract_workflow(new_set, id = "none_cart")
#> ══ Workflow ══════════════════════════════════════════════════════════════
#> Preprocessor: Formula
#> Model: decision_tree()
#> 
#> ── Preprocessor ──────────────────────────────────────────────────────────
#> Class ~ A + B
#> 
#> ── Model ─────────────────────────────────────────────────────────────────
#> Decision Tree Model Specification (classification)
#> 
#> Engine-Specific Arguments:
#>   method = anova
#> 
#> Computational engine: rpart 
#>