Fitting a workflow currently involves two main steps:

# S3 method for workflow
fit(object, data, ..., control = control_workflow())

Arguments

object

A workflow

data

A data frame of predictors and outcomes to use when fitting the workflow

...

Not used

control

A control_workflow() object

Value

The workflow object, updated with a fit parsnip model in the object$fit$fit slot.

Details

In the future, there will also be postprocessing steps that can be added after the model has been fit.

Examples

library(parsnip) library(recipes) model <- linear_reg() model <- set_engine(model, "lm") base_workflow <- workflow() base_workflow <- add_model(base_workflow, model) formula_workflow <- add_formula(base_workflow, mpg ~ cyl + log(disp)) fit(formula_workflow, mtcars)
#> ══ Workflow [trained] ══════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ──────────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ─────────────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = formula, data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #>
recipe <- recipe(mpg ~ cyl + disp, mtcars) recipe <- step_log(recipe, disp) recipe_workflow <- add_recipe(base_workflow, recipe) fit(recipe_workflow, mtcars)
#> ══ Workflow [trained] ══════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: linear_reg() #> #> ── Preprocessor ──────────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> ● step_log() #> #> ── Model ─────────────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = formula, data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 67.6674 -0.1755 -8.7971 #>