Skip to content

Use existing objects to create a workflow set. A list of objects that are either simple workflows or objects that have class "tune_results is converted into a workflow set.

Usage

as_workflow_set(...)

Arguments

...

One or more named objects. Names should be unique and the objects should have at least one of the following classes: workflow, iteration_results, tune_results, resample_results, or tune_race. Each tune_results element should also contain the original workflow (accomplished using the save_workflow option in the control function).

Value

A workflow set. Note that the option column will not reflect the options that were used to create each object.

Examples


# ------------------------------------------------------------------------------
# Existing results

# Use the already worked example to show how to add tuned
# objects to a workflow set

results <- two_class_res %>% purrr::pluck("result")
names(results) <- two_class_res$wflow_id

# These are all objects that have been resampled or tuned:
purrr::map_chr(results, ~ class(.x)[1])
#>          none_cart           none_glm          none_mars 
#>     "tune_results" "resample_results"     "tune_results" 
#>      yj_trans_cart       yj_trans_glm      yj_trans_mars 
#>     "tune_results" "resample_results"     "tune_results" 

# Use rlang's !!! operator to splice in the elements of the list
new_set <- as_workflow_set(!!!results)

# ------------------------------------------------------------------------------
# Make a set from unfit workflows

library(parsnip)
library(workflows)

lr_spec <- logistic_reg()

main_effects <-
  workflow() %>%
  add_model(lr_spec) %>%
  add_formula(Class ~ .)

interactions <-
  workflow() %>%
  add_model(lr_spec) %>%
  add_formula(Class ~ (.)^2)

as_workflow_set(main = main_effects, int = interactions)
#> # A workflow set/tibble: 2 × 4
#>   wflow_id info             option    result
#>   <chr>    <list>           <list>    <list>
#> 1 main     <tibble [1 × 4]> <opts[0]> <NULL>
#> 2 int      <tibble [1 × 4]> <opts[0]> <NULL>