Description Usage Arguments Value Examples
Please use the extract_*()
functions instead of these
(e.g. extract_mold()
).
These functions extract various elements from a workflow object. If they do not exist yet, an error is thrown.
pull_workflow_preprocessor()
returns the formula, recipe, or variable
expressions used for preprocessing.
pull_workflow_spec()
returns the parsnip model specification.
pull_workflow_fit()
returns the parsnip model fit.
pull_workflow_mold()
returns the preprocessed "mold" object returned
from hardhat::mold()
. It contains information about the preprocessing,
including either the prepped recipe or the formula terms object.
pull_workflow_prepped_recipe()
returns the prepped recipe. It is
extracted from the mold object returned from pull_workflow_mold()
.
1 2 3 4 5 6 7 8 9 
x 
A workflow 
The extracted value from the workflow, x
, as described in the description
section.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  library(parsnip)
library(recipes)
library(magrittr)
model < linear_reg() %>%
set_engine("lm")
recipe < recipe(mpg ~ cyl + disp, mtcars) %>%
step_log(disp)
base_wf < workflow() %>%
add_model(model)
recipe_wf < add_recipe(base_wf, recipe)
formula_wf < add_formula(base_wf, mpg ~ cyl + log(disp))
variable_wf < add_variables(base_wf, mpg, c(cyl, disp))
fit_recipe_wf < fit(recipe_wf, mtcars)
fit_formula_wf < fit(formula_wf, mtcars)
# The preprocessor is a recipes, formula, or a list holding the
# tidyselect expressions identifying the outcomes/predictors
pull_workflow_preprocessor(recipe_wf)
pull_workflow_preprocessor(formula_wf)
pull_workflow_preprocessor(variable_wf)
# The `spec` is the parsnip spec before it has been fit.
# The `fit` is the fit parsnip model.
pull_workflow_spec(fit_formula_wf)
pull_workflow_fit(fit_formula_wf)
# The mold is returned from `hardhat::mold()`, and contains the
# predictors, outcomes, and information about the preprocessing
# for use on new data at `predict()` time.
pull_workflow_mold(fit_recipe_wf)
# A useful shortcut is to extract the prepped recipe from the workflow
pull_workflow_prepped_recipe(fit_recipe_wf)
# That is identical to
identical(
pull_workflow_mold(fit_recipe_wf)$blueprint$recipe,
pull_workflow_prepped_recipe(fit_recipe_wf)
)

Loading required package: dplyr
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Attaching package: ‘recipes’
The following object is masked from ‘package:stats’:
step
Data Recipe
Inputs:
role #variables
outcome 1
predictor 2
Operations:
Log transformation on disp
mpg ~ cyl + log(disp)
$outcomes
<quosure>
expr: ^mpg
env: global
$predictors
<quosure>
expr: ^c(cyl, disp)
env: global
Linear Regression Model Specification (regression)
Computational engine: lm
parsnip model object
Fit time: 1ms
Call:
stats::lm(formula = ..y ~ ., data = data)
Coefficients:
(Intercept) cyl `log(disp)`
67.6674 0.1755 8.7971
$predictors
# A tibble: 32 x 2
cyl disp
<dbl> <dbl>
1 6 5.08
2 6 5.08
3 4 4.68
4 6 5.55
5 8 5.89
6 6 5.42
7 8 5.89
8 4 4.99
9 4 4.95
10 6 5.12
# … with 22 more rows
$outcomes
# A tibble: 32 x 1
mpg
<dbl>
1 21
2 21
3 22.8
4 21.4
5 18.7
6 18.1
7 14.3
8 24.4
9 22.8
10 19.2
# … with 22 more rows
$blueprint
Recipe blueprint:
# Predictors: 2
# Outcomes: 1
Intercept: FALSE
Novel Levels: FALSE
Composition: tibble
$extras
$extras$roles
NULL
Data Recipe
Inputs:
role #variables
outcome 1
predictor 2
Training data contained 32 data points and no missing data.
Operations:
Log transformation on disp [trained]
[1] TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.