Learn R Programming

workflowsets (version 1.1.0)

as_workflow_set: Convert existing objects to a workflow set

Description

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

Usage

as_workflow_set(...)

Value

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

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).

Examples

Run this code

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

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

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])

# 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)

Run the code above in your browser using DataLab