Fitting a workflow currently involves two main steps:
Preprocessing the data using a formula preprocessor, or by calling
recipes::prep()
on a recipe.
Fitting the underlying parsnip model using parsnip::fit.model_spec()
.
# S3 method for workflow
fit(object, data, ..., control = control_workflow())
A workflow
A data frame of predictors and outcomes to use when fitting the workflow
Not used
A control_workflow()
object
The workflow object
, updated with a fit parsnip model in the
object$fit$fit
slot.
In the future, there will also be postprocessing steps that can be added after the model has been fit.
# NOT RUN {
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)
recipe <- recipe(mpg ~ cyl + disp, mtcars)
recipe <- step_log(recipe, disp)
recipe_workflow <- add_recipe(base_workflow, recipe)
fit(recipe_workflow, mtcars)
# }
Run the code above in your browser using DataLab