From 7fabb5de1f5b6228c2a80d34a7f1a6ddfeb6e385 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Mon, 21 Oct 2024 15:12:43 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tidymode?= =?UTF-8?q?ls/workflows@15485263e52ef8c6b492093680f96cab5cedf411=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/pkgdown.yml | 2 +- dev/reference/extract-workflow.html | 6 +++--- dev/reference/workflow-extractors.html | 6 +++--- dev/search.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 85a9d9e..866b477 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: extras/getting-started: extras/getting-started.html stages: stages.html -last_built: 2024-10-21T15:07Z +last_built: 2024-10-21T15:12Z urls: reference: https://workflows.tidymodels.org/reference article: https://workflows.tidymodels.org/articles diff --git a/dev/reference/extract-workflow.html b/dev/reference/extract-workflow.html index 1babcb6..e51b873 100644 --- a/dev/reference/extract-workflow.html +++ b/dev/reference/extract-workflow.html @@ -219,17 +219,17 @@

Examples#> Log transformation on: disp extract_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) -#> <environment: 0x55bbc75c7f40> +#> <environment: 0x562a17537340> extract_preprocessor(variable_wf) #> $outcomes #> <quosure> #> expr: ^mpg -#> env: 0x55bbc75c7f40 +#> env: 0x562a17537340 #> #> $predictors #> <quosure> #> expr: ^c(cyl, disp) -#> env: 0x55bbc75c7f40 +#> env: 0x562a17537340 #> #> attr(,"class") #> [1] "workflow_variables" diff --git a/dev/reference/workflow-extractors.html b/dev/reference/workflow-extractors.html index c4ee3cd..c5f5a21 100644 --- a/dev/reference/workflow-extractors.html +++ b/dev/reference/workflow-extractors.html @@ -146,17 +146,17 @@

Examples#> Log transformation on: disp pull_workflow_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) -#> <environment: 0x55bbcc9fe268> +#> <environment: 0x562a1ccdb898> pull_workflow_preprocessor(variable_wf) #> $outcomes #> <quosure> #> expr: ^mpg -#> env: 0x55bbcc9fe268 +#> env: 0x562a1ccdb898 #> #> $predictors #> <quosure> #> expr: ^c(cyl, disp) -#> env: 0x55bbcc9fe268 +#> env: 0x562a1ccdb898 #> #> attr(,"class") #> [1] "workflow_variables" diff --git a/dev/search.json b/dev/search.json index 8faf01c..3a71fd6 100644 --- a/dev/search.json +++ b/dev/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tidymodels","title":"Contributing to tidymodels","text":"detailed information contributing tidymodels packages, see development contributing guide.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Contributing to tidymodels","text":"Typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES ✅: edit roxygen comment .R file R/ directory. 🚫: edit .Rd file man/ directory. use roxygen2, Markdown syntax, documentation.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"code","dir":"","previous_headings":"","what":"Code","title":"Contributing to tidymodels","text":"submit 🎯 pull request tidymodels package, always file issue confirm tidymodels team agrees idea happy basic proposal. tidymodels packages work together. package contains unit tests, integration tests tests using packages contained extratests. recommend create Git branch pull request (PR). Look build status making changes. README contains badges continuous integration services used package. New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s). use testthat. Contributions test cases included easier accept. contribution spans use one package, consider building extratests changes check breakages /adding new tests . Let us know PR ran extra tests.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"Code","what":"Code of Conduct","title":"Contributing to tidymodels","text":"project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://workflows.tidymodels.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 workflows authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"current-state","dir":"","previous_headings":"","what":"Current state","title":"NA","text":"Workflows stable. currently supports implemented model types tidymodels, including censored modeltime. Often looks like model type supported typical workflows model, user can supply “model formula” gets passed directly parsnip workaround (.e. add_model(formula = )). general model workflows split 3 stages: pre, fit, post. pre controls preprocessing, divided “actions”. formula, recipes, variables actions correspond 3 preprocessor types hardhat. can use one per workflow. case weights action controls case weights extracted data passed parsnip model. Internally force action run preprocessor actions. fit controls model fit. 1 “model” action , anticipate actions stage workflow. post controls postprocessing. 1 “tailor” action , though may others future. workflow specified, fit() called fit “actions”. loops actions workflow, calls fit() actions well (S3 methods fit() action). similar recipes, step prep() method. Keep mind people save fitted workflows reload prediction, considerations backwards compatibility. time add new feature, change existing one, need keep mind whether old workflows saved disk continue run new version workflows. Historically problem hardhat, backwards compatibility issues seem like hardhat problem, suggest adding backwards compatibility tests hardhat directly instead.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"known-issues","dir":"","previous_headings":"","what":"Known issues","title":"NA","text":"think still don’t support parsnip::multi_predict(). time remember seeing clear way integrate , maybe landscape changed since https://github.com/tidymodels/workflows/issues/4.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"future-directions","dir":"","previous_headings":"","what":"Future directions","title":"NA","text":"known feature want add workflows support postprocessing. mentioned , requires tooling probably package, along tight integration tune (likely need 3rd inner loop control tuning postprocessing options).","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"introduction","dir":"Articles > Extras","previous_headings":"","what":"Introduction","title":"Getting Started","text":"bivariate data set, two predictors can used differentiate two classes outcome. three partitions original data: training (n = 1009), validation (n = 300), testing (n = 710). work training set , use validation set compare models development process, use test set think good algorithm making predictions. training set: predictors positive values distributions right-skewed. seems separation classes, variables used together. example, predictors visualized individually, little evidence separation classes. first plot , separation appears happen linearly, straight, diagonal boundary might well. use glm() directly create logistic regression, use tidymodels infrastructure start making parsnip model object. data analysis involve looking different approaches representing two predictors high-quality model. ’ll walk though thought process analysis go. emulate data analysis projects happen: initial approach taken potential steps attempted make improvements. pre-defined blueprint process R4DS diagram summarizes process nicely. Since going try different combinations feature engineering models, workflows really useful since can one object contains operations. helps organize work instead different objects workspace , point, used pairs.","code":"library(modeldata) # This gives us access to the 3 partitions: # - `bivariate_train`: Training set # - `bivariate_val`: Validation set # - `bivariate_test`: Test set data(\"bivariate\") library(workflows) library(ggplot2) library(dplyr) ggplot(bivariate_train, aes(x = A, y = B, col = Class)) + geom_point(alpha = .3) + coord_equal(ratio = 20) library(tidyr) bivariate_train %>% pivot_longer(cols = c(A, B), names_to = \"predictor\") %>% ggplot(aes(x = Class, y = value)) + geom_boxplot() + facet_wrap(~predictor, scales = \"free_y\") + scale_y_log10() library(parsnip) logit_mod <- logistic_reg() %>% set_engine(\"glm\")"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"a-first-set-of-models","dir":"Articles > Extras","previous_headings":"","what":"A first set of models","title":"Getting Started","text":"obvious place start adding predictors -model: evaluate model, ROC curve computed along corresponding AUC. seems reasonable. One potential issue two predictors high degree correlation 0.848, might cause instability model. Since two correlated predictors skewed distributions strictly positive values, might intuitive use ratio instead pair. ’ll try next recycling initial workflow just adding different formula: original analysis shows slight edge, two models probably within experimental noise one another.","code":"# Create a workflow with just the model. We will add to this as we go. glm_workflow <- workflow() %>% add_model(logit_mod) simple_glm <- glm_workflow %>% # Add both predictors in add_formula(Class ~ .) %>% # Fit the model: fit(data = bivariate_train) library(yardstick) simple_glm_probs <- predict(simple_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) simple_glm_roc <- simple_glm_probs %>% roc_curve(Class, .pred_One) simple_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.773 autoplot(simple_glm_roc) ratio_glm <- glm_workflow %>% add_formula(Class ~ I(A/B)) %>% fit(data = bivariate_train) ratio_glm_probs <- predict(ratio_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) ratio_glm_roc <- ratio_glm_probs %>% roc_curve(Class, .pred_One) ratio_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.765 autoplot(simple_glm_roc) + geom_path( data = ratio_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#FDE725FF\" )"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"more-complex-feature-engineering","dir":"Articles > Extras","previous_headings":"","what":"More complex feature engineering","title":"Getting Started","text":"Instead combining two predictors, help model resolve skewness variables? test theory, one option use Box-Cox transformation predictor individually see recommends nonlinear transformation. transformation can encode variety different functions including log transform, square root, inverse, fractional transformations -. easily done via formula interface, recipe used. recipe list sequential data processing steps conducted data used model. example, use Box-Cox method, simple recipe : Creating recipe makes object instructions; carry instructions (e.g. estimate transformation parameter). actually execute recipe, add workflow add_recipe() call fit(). Fitting workflow evaluates model recipe. potential, slight, improvement. Box-Cox procedure recommended transformations pretty close inverse. model creates class boundary data: correlation original data. might help model de-correlate , standard technique principal component analysis. recipe step can added conduct PCA return score values. scores, instead original predictors, can used model. PCA chases variability, important normalize two predictors units. Traditionally, column centered scaled. reason, step used prior PCA normalizes two predictors. results almost identical transformed model.","code":"library(recipes) trans_recipe <- recipe(Class ~ ., data = bivariate_train) %>% step_BoxCox(all_predictors()) trans_glm <- glm_workflow %>% add_recipe(trans_recipe) %>% fit(data = bivariate_train) trans_glm_probs <- predict(trans_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) trans_glm_roc <- trans_glm_probs %>% roc_curve(Class, .pred_One) trans_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.815 autoplot(simple_glm_roc) + geom_path( data = ratio_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#FDE725FF\" ) + geom_path( data = trans_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#21908CFF\" ) ggplot(bivariate_train, aes(x = 1/A, y = 1/B, col = Class)) + geom_point(alpha = .3) + coord_equal(ratio = 1/12) pca_recipe <- trans_recipe %>% step_normalize(A, B) %>% step_pca(A, B, num_comp = 2) pca_glm <- glm_workflow %>% add_recipe(pca_recipe) %>% fit(data = bivariate_train) pca_glm_probs <- predict(pca_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) pca_glm_roc <- pca_glm_probs %>% roc_curve(Class, .pred_One) pca_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.815"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"the-test-set","dir":"Articles > Extras","previous_headings":"","what":"The test set","title":"Getting Started","text":"Based results, model logistic regression model inverse terms probably best bet. Using test set:","code":"test_probs <- predict(trans_glm, bivariate_test, type = \"prob\") %>% bind_cols(bivariate_test) test_roc <- test_probs %>% roc_curve(Class, .pred_One) # A little more optimistic than the validation set test_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.862 autoplot(test_roc)"},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"pre-processing","dir":"Articles","previous_headings":"","what":"Pre-processing","title":"Workflow Stages","text":"three elements allowed pre-processing : standard model formula via add_formula(). tidyselect interface via add_variables() strictly preserves class columns. recipe object via add_recipe(). can use one .","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"model-fitting","dir":"Articles","previous_headings":"","what":"Model Fitting","title":"Workflow Stages","text":"parsnip model specifications option , specified via add_model(). using preprocessor, may need additional formula special model terms (e.g. mixed models generalized linear models). cases, specify formula using add_model()’s formula argument, passed underlying model fit() called.","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"post-processing","dir":"Articles","previous_headings":"","what":"Post-processing","title":"Workflow Stages","text":"tailor post-processors option , specified via add_tailor(). examples post-processing model predictions include adding probability threshold two-class problems, calibration probability estimates, truncating possible range predictions, .","code":""},{"path":"https://workflows.tidymodels.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Davis Vaughan. Author. Simon Couch. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://workflows.tidymodels.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Vaughan D, Couch S (2024). workflows: Modeling Workflows. R package version 1.1.4.9000, https://workflows.tidymodels.org, https://github.com/tidymodels/workflows.","code":"@Manual{, title = {workflows: Modeling Workflows}, author = {Davis Vaughan and Simon Couch}, year = {2024}, note = {R package version 1.1.4.9000, https://workflows.tidymodels.org}, url = {https://github.com/tidymodels/workflows}, }"},{"path":[]},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"what-is-a-workflow","dir":"","previous_headings":"","what":"What is a workflow?","title":"Modeling Workflows","text":"workflow object can bundle together pre-processing, modeling, post-processing requests. example, recipe parsnip model, can combined workflow. advantages : don’t keep track separate objects workspace. recipe prepping, model fitting, postprocessor estimation (may include data splitting) can executed using single call fit(). custom tuning parameter settings, can defined using simpler interface combined tune.","code":""},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Modeling Workflows","text":"can install workflows CRAN : can install development version GitHub :","code":"install.packages(\"workflows\") # install.packages(\"pak\") pak::pak(\"tidymodels/workflows\")"},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Modeling Workflows","text":"Suppose modeling data cars. Say…fuel efficiency 32 cars. know relationship engine displacement miles-per-gallon nonlinear, like model spline adding Bayesian linear regression model. might recipe specify spline: model object: use , generally run: can’t predict new samples using bayes_lm_fit without prepped version spline_cars around. also might models recipes workspace. might lead getting mixed-forgetting save model/recipe pair interested . workflows makes easier combining objects together: Now can prepare recipe estimate model via single call fit(): can alter existing workflows using update_recipe() / update_model() remove_recipe() / remove_model().","code":"library(recipes) library(parsnip) library(workflows) spline_cars <- recipe(mpg ~ ., data = mtcars) %>% step_ns(disp, deg_free = 10) bayes_lm <- linear_reg() %>% set_engine(\"stan\") spline_cars_prepped <- prep(spline_cars, mtcars) bayes_lm_fit <- fit(bayes_lm, mpg ~ ., data = juice(spline_cars_prepped)) car_wflow <- workflow() %>% add_recipe(spline_cars) %>% add_model(bayes_lm) car_wflow_fit <- fit(car_wflow, data = mtcars)"},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Modeling Workflows","text":"project released Contributor Code Conduct. contributing project, agree abide terms. questions discussions tidymodels packages, modeling, machine learning, please post Posit Community. think encountered bug, please submit issue. Either way, learn create share reprex (minimal, reproducible example), clearly communicate code. Check details contributing guidelines tidymodels packages get help.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":null,"dir":"Reference","previous_headings":"","what":"Add case weights to a workflow — add_case_weights","title":"Add case weights to a workflow — add_case_weights","text":"family functions revolves around selecting column data use case weights. column must one allowed case weight types, hardhat::frequency_weights() hardhat::importance_weights(). Specifically, must return TRUE hardhat::is_case_weights(). underlying model decide whether type case weights supplied applicable . add_case_weights() specifies column interpreted case weights model. column must present data supplied fit(). remove_case_weights() removes case weights. Additionally, model already fit, fit removed. update_case_weights() first removes case weights, replaces new ones.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add case weights to a workflow — add_case_weights","text":"","code":"add_case_weights(x, col) remove_case_weights(x) update_case_weights(x, col)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add case weights to a workflow — add_case_weights","text":"x workflow col single unquoted column name specifying case weights model. must classed case weights column, determined hardhat::is_case_weights().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add case weights to a workflow — add_case_weights","text":"formula variable preprocessors, case weights col removed data preprocessor evaluated. allows use formulas like y ~ . tidyselection like everything() without fear accidentally selecting case weights column. recipe preprocessors, case weights col removed passed along recipe. Typically, recipe include steps can utilize case weights.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add case weights to a workflow — add_case_weights","text":"","code":"library(parsnip) library(magrittr) library(hardhat) mtcars2 <- mtcars mtcars2$gear <- frequency_weights(mtcars2$gear) spec <- linear_reg() %>% set_engine(\"lm\") wf <- workflow() %>% add_case_weights(gear) %>% add_formula(mpg ~ .) %>% add_model(spec) wf <- fit(wf, mtcars2) # Notice that the case weights (gear) aren't included in the predictors extract_mold(wf)$predictors #> # A tibble: 32 × 10 #> `(Intercept)` cyl disp hp drat wt qsec vs am carb #> #> 1 1 6 160 110 3.9 2.62 16.5 0 1 4 #> 2 1 6 160 110 3.9 2.88 17.0 0 1 4 #> 3 1 4 108 93 3.85 2.32 18.6 1 1 1 #> 4 1 6 258 110 3.08 3.22 19.4 1 0 1 #> 5 1 8 360 175 3.15 3.44 17.0 0 0 2 #> 6 1 6 225 105 2.76 3.46 20.2 1 0 1 #> 7 1 8 360 245 3.21 3.57 15.8 0 0 4 #> 8 1 4 147. 62 3.69 3.19 20 1 0 2 #> 9 1 4 141. 95 3.92 3.15 22.9 1 0 2 #> 10 1 6 168. 123 3.92 3.44 18.3 1 0 4 #> # ℹ 22 more rows # Strip them out of the workflow, which also resets the model remove_case_weights(wf) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #>"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":null,"dir":"Reference","previous_headings":"","what":"Add formula terms to a workflow — add_formula","title":"Add formula terms to a workflow — add_formula","text":"add_formula() specifies terms model usage formula. remove_formula() removes formula well downstream objects might get created formula used preprocessing, terms. Additionally, model already fit, fit removed. update_formula() first removes formula, replaces previous formula new one. model already fit based formula need refit.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add formula terms to a workflow — add_formula","text":"","code":"add_formula(x, formula, ..., blueprint = NULL) remove_formula(x) update_formula(x, formula, ..., blueprint = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add formula terms to a workflow — add_formula","text":"x workflow formula formula specifying terms model. advised preprocessing formula, instead use recipe required. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_formula_blueprint() used passed arguments best align model present workflow. Note preprocessing done separate preprocessing might done underlying model. example, blueprint indicators = \"none\" specified, dummy variables created hardhat, underlying model requires formula interface internally uses stats::model.matrix(), factors still expanded dummy variables model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add formula terms to a workflow — add_formula","text":"x, updated either new removed formula preprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add formula terms to a workflow — add_formula","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"formula-handling","dir":"Reference","previous_headings":"","what":"Formula Handling","title":"Add formula terms to a workflow — add_formula","text":"Note , different models, formula given add_formula() might handled different ways, depending parsnip model used. example, random forest model fit using ranger convert factor predictors binary indicator variables. consistent ranger::ranger() , inconsistent stats::model.matrix() . documentation parsnip models provides details data given formula encoded model diverge standard model.matrix() methodology. goal consistent underlying model package works.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"how-is-this-formula-used-","dir":"Reference","previous_headings":"","what":"How is this formula used?","title":"Add formula terms to a workflow — add_formula","text":"demonstrate, example uses lm() fit model. formula given add_formula() used create model matrix passed lm() simple formula body_mass_g ~ .: can affect results analyzed. example, get sequential hypothesis tests, individual term tested:","code":"library(parsnip) library(workflows) library(magrittr) library(modeldata) library(hardhat) data(penguins) lm_mod <- linear_reg() %>% set_engine(\"lm\") lm_wflow <- workflow() %>% add_model(lm_mod) pre_encoded <- lm_wflow %>% add_formula(body_mass_g ~ species + island + bill_depth_mm) %>% fit(data = penguins) pre_encoded_parsnip_fit <- pre_encoded %>% extract_fit_parsnip() pre_encoded_fit <- pre_encoded_parsnip_fit$fit # The `lm()` formula is *not* the same as the `add_formula()` formula: pre_encoded_fit ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) speciesChinstrap speciesGentoo ## -1009.943 1.328 2236.865 ## islandDream islandTorgersen bill_depth_mm ## 9.221 -18.433 256.913 anova(pre_encoded_fit) ## Analysis of Variance Table ## ## Response: ..y ## Df Sum Sq Mean Sq F value Pr(>F) ## speciesChinstrap 1 18642821 18642821 141.1482 <2e-16 *** ## speciesGentoo 1 128221393 128221393 970.7875 <2e-16 *** ## islandDream 1 13399 13399 0.1014 0.7503 ## islandTorgersen 1 255 255 0.0019 0.9650 ## bill_depth_mm 1 28051023 28051023 212.3794 <2e-16 *** ## Residuals 336 44378805 132080 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"overriding-the-default-encodings","dir":"Reference","previous_headings":"","what":"Overriding the default encodings","title":"Add formula terms to a workflow — add_formula","text":"Users can override model-specific encodings using hardhat blueprint. blueprint can specify factors encoded whether intercepts included. example, use formula like data passed model untouched: looks , raw columns given lm() function created dummy variables. , sequential ANOVA tests groups parameters get column-level p-values:","code":"minimal <- default_formula_blueprint(indicators = \"none\", intercept = FALSE) un_encoded <- lm_wflow %>% add_formula( body_mass_g ~ species + island + bill_depth_mm, blueprint = minimal ) %>% fit(data = penguins) un_encoded_parsnip_fit <- un_encoded %>% extract_fit_parsnip() un_encoded_fit <- un_encoded_parsnip_fit$fit un_encoded_fit ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) bill_depth_mm speciesChinstrap ## -1009.943 256.913 1.328 ## speciesGentoo islandDream islandTorgersen ## 2236.865 9.221 -18.433 anova(un_encoded_fit) ## Analysis of Variance Table ## ## Response: ..y ## Df Sum Sq Mean Sq F value Pr(>F) ## bill_depth_mm 1 48840779 48840779 369.782 <2e-16 *** ## species 2 126067249 63033624 477.239 <2e-16 *** ## island 2 20864 10432 0.079 0.9241 ## Residuals 336 44378805 132080 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"overriding-the-default-model-formula","dir":"Reference","previous_headings":"","what":"Overriding the default model formula","title":"Add formula terms to a workflow — add_formula","text":"Additionally, formula passed underlying model can also customized. case, formula argument add_model() can used. demonstrate, spline function used bill depth:","code":"library(splines) custom_formula <- workflow() %>% add_model( lm_mod, formula = body_mass_g ~ species + island + ns(bill_depth_mm, 3) ) %>% add_formula( body_mass_g ~ species + island + bill_depth_mm, blueprint = minimal ) %>% fit(data = penguins) custom_parsnip_fit <- custom_formula %>% extract_fit_parsnip() custom_fit <- custom_parsnip_fit$fit custom_fit ## ## Call: ## stats::lm(formula = body_mass_g ~ species + island + ns(bill_depth_mm, ## 3), data = data) ## ## Coefficients: ## (Intercept) speciesChinstrap speciesGentoo ## 1959.090 8.534 2352.137 ## islandDream islandTorgersen ns(bill_depth_mm, 3)1 ## 2.425 -12.002 1476.386 ## ns(bill_depth_mm, 3)2 ns(bill_depth_mm, 3)3 ## 3187.839 1686.996"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"altering-the-formula","dir":"Reference","previous_headings":"","what":"Altering the formula","title":"Add formula terms to a workflow — add_formula","text":"Finally, formula updated removed fitted workflow, corresponding model fit removed.","code":"custom_formula_no_fit <- update_formula(custom_formula, body_mass_g ~ species) try(extract_fit_parsnip(custom_formula_no_fit)) ## Error in extract_fit_parsnip(custom_formula_no_fit) : ## Can't extract a model fit from an untrained workflow. ## i Do you need to call `fit()`?"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add formula terms to a workflow — add_formula","text":"","code":"workflow <- workflow() workflow <- add_formula(workflow, mpg ~ cyl) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl remove_formula(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_formula(workflow, mpg ~ disp) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ disp"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a model to a workflow — add_model","title":"Add a model to a workflow — add_model","text":"add_model() adds parsnip model workflow. remove_model() removes model specification well fitted model object. extra formulas also removed. update_model() first removes model adds new specification workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a model to a workflow — add_model","text":"","code":"add_model(x, spec, ..., formula = NULL) remove_model(x) update_model(x, spec, ..., formula = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a model to a workflow — add_model","text":"x workflow. spec parsnip model specification. ... dots future extensions must empty. formula optional formula override specify terms model. Typically, terms extracted formula recipe preprocessing methods. However, models (like survival bayesian models) use formula preprocess, specify structure model. cases, formula specifying model structure must passed unchanged model call . argument used purposes.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a model to a workflow — add_model","text":"x, updated either new removed model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a model to a workflow — add_model","text":"add_model() required step construct minimal workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Add a model to a workflow — add_model","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Add a model to a workflow — add_model","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Add a model to a workflow — add_model","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a model to a workflow — add_model","text":"","code":"library(parsnip) lm_model <- linear_reg() lm_model <- set_engine(lm_model, \"lm\") regularized_model <- set_engine(lm_model, \"glmnet\") workflow <- workflow() workflow <- add_model(workflow, lm_model) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: linear_reg() #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> workflow <- add_formula(workflow, mpg ~ .) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> remove_model(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . fitted <- fit(workflow, data = mtcars) fitted #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp hp drat #> 12.30337 -0.11144 0.01334 -0.02148 0.78711 #> wt qsec vs am gear #> -3.71530 0.82104 0.31776 2.52023 0.65541 #> carb #> -0.19942 #> remove_model(fitted) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . remove_model(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . update_model(workflow, regularized_model) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: glmnet #> update_model(fitted, regularized_model) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: glmnet #>"},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a recipe to a workflow — add_recipe","title":"Add a recipe to a workflow — add_recipe","text":"add_recipe() specifies terms model preprocessing required usage recipe. remove_recipe() removes recipe well downstream objects might get created recipe used preprocessing, prepped recipe. Additionally, model already fit, fit removed. update_recipe() first removes recipe, replaces previous recipe new one. model already fit based recipe need refit.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a recipe to a workflow — add_recipe","text":"","code":"add_recipe(x, recipe, ..., blueprint = NULL) remove_recipe(x) update_recipe(x, recipe, ..., blueprint = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a recipe to a workflow — add_recipe","text":"x workflow recipe recipe created using recipes::recipe(). recipe trained already recipes::prep(); workflows handle training internally. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_recipe_blueprint() used. Note preprocessing done separate preprocessing might done automatically underlying model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a recipe to a workflow — add_recipe","text":"x, updated either new removed recipe preprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a recipe to a workflow — add_recipe","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a recipe to a workflow — add_recipe","text":"","code":"library(recipes) #> 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 library(magrittr) recipe <- recipe(mpg ~ cyl, mtcars) %>% step_log(cyl) workflow <- workflow() %>% add_recipe(recipe) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> • step_log() remove_recipe(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_recipe(workflow, recipe(mpg ~ cyl, mtcars)) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 0 Recipe Steps"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a tailor to a workflow — add_tailor","title":"Add a tailor to a workflow — add_tailor","text":"add_tailor() specifies post-processing steps apply usage tailor. remove_tailor() removes tailor well downstream objects might get created tailor used post-processing, fitted tailor. update_tailor() first removes tailor, replaces previous tailor new one.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a tailor to a workflow — add_tailor","text":"","code":"add_tailor(x, tailor, ...) remove_tailor(x) update_tailor(x, tailor, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a tailor to a workflow — add_tailor","text":"x workflow tailor tailor created using tailor::tailor(). tailor trained already tailor::fit(); workflows handle training internally. ... used.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a tailor to a workflow — add_tailor","text":"x, updated either new removed tailor postprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Add a tailor to a workflow — add_tailor","text":"preprocessors models trained data usual sense, postprocessors training predictions data. workflow fitted, user typically supplies training data data argument. workflows contain postprocessor requires training, users can pass available data data argument train preprocessor model. However, case postprocessor must trained well, allotting available data data argument train preprocessor model leave data train postprocessor —case, workflows need predict() preprocessor model data trained , postprocessor training predictions. Predictions data model trained likely follow different distributions predictions unseen data; thus, workflows must split supplied data two training sets, first used train preprocessor model second, called \"calibration set,\" passed trained postprocessor model generate predictions, form training data postprocessor. fitting workflow postprocessor requires training (.e. one returns TRUE .workflow_includes_calibration(workflow)), users must pass two data arguments–usual fit.workflow(data) used train preprocessor model fit.workflow(calibration) used train postprocessor. situations, randomly splitting fit.workflow(data) (rsample::initial_split(), example) sufficient prevent data leakage. However, fit.workflow(data) also arisen : case, rows data duplicated. Thus, randomly allotting train preprocessor model others train preprocessor likely result rows appearing datasets, resulting preprocessor model generating predictions rows seen . Similarly problematic situations arise context resampling situations, like time-based splits. general, use rsample::inner_split() function prevent data leakage resampling; workflows postprocessors require training passed tune package, handled internally.","code":"boots <- rsample::bootstraps(some_other_data) split <- rsample::get_rsplit(boots, 1) data <- rsample::analysis(split)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a tailor to a workflow — add_tailor","text":"","code":"library(tailor) library(magrittr) tailor <- tailor() tailor_1 <- adjust_probability_threshold(tailor, .1) workflow <- workflow() %>% add_tailor(tailor_1) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None #> Postprocessor: tailor #> #> ── Postprocessor ───────────────────────────────────────────────────────── #> #> ── tailor ──────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. #> NA #> NA #> NA remove_tailor(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_tailor(workflow, adjust_probability_threshold(tailor, .2)) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None #> Postprocessor: tailor #> #> ── Postprocessor ───────────────────────────────────────────────────────── #> #> ── tailor ──────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.2. #> NA #> NA #> NA"},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variables to a workflow — add_variables","title":"Add variables to a workflow — add_variables","text":"add_variables() specifies terms model usage tidyselect::select_helpers outcomes predictors. remove_variables() removes variables. Additionally, model already fit, fit removed. update_variables() first removes variables, replaces previous variables new ones. model already fit based original variables need refit. workflow_variables() bundles outcomes predictors single variables object, can supplied add_variables().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variables to a workflow — add_variables","text":"","code":"add_variables(x, outcomes, predictors, ..., blueprint = NULL, variables = NULL) remove_variables(x) update_variables( x, outcomes, predictors, ..., blueprint = NULL, variables = NULL ) workflow_variables(outcomes, predictors)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variables to a workflow — add_variables","text":"x workflow outcomes, predictors Tidyselect expressions specifying terms model. outcomes evaluated first, outcome columns removed data predictors evaluated. See tidyselect::select_helpers full range possible ways specify terms. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_xy_blueprint() used. Note preprocessing done separate preprocessing might done underlying model. variables alternative specification outcomes predictors, useful supplying variables programmatically. NULL, argument unused, outcomes predictors used specify variables. Otherwise, must result calling workflow_variables() create standalone variables object. case, outcomes predictors completely ignored.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variables to a workflow — add_variables","text":"add_variables() returns x new variables preprocessor. remove_variables() returns x resetting model fit removing variables preprocessor. update_variables() returns x removing variables preprocessor, re-specifying new variables. workflow_variables() returns 'workflow_variables' object containing outcomes predictors.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add variables to a workflow — add_variables","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variables to a workflow — add_variables","text":"","code":"library(parsnip) spec_lm <- linear_reg() spec_lm <- set_engine(spec_lm, \"lm\") workflow <- workflow() workflow <- add_model(workflow, spec_lm) # Add terms with tidyselect expressions. # Outcomes are specified before predictors. workflow1 <- add_variables( workflow, outcomes = mpg, predictors = c(cyl, disp) ) workflow1 <- fit(workflow1, mtcars) workflow1 #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: c(cyl, disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 34.66099 -1.58728 -0.02058 #> # Removing the variables of a fit workflow will also remove the model remove_variables(workflow1) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: linear_reg() #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> # Variables can also be updated update_variables(workflow1, mpg, starts_with(\"d\")) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: starts_with(\"d\") #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> # The `outcomes` are removed before the `predictors` expression # is evaluated. This allows you to easily specify the predictors # as \"everything except the outcomes\". workflow2 <- add_variables(workflow, mpg, everything()) workflow2 <- fit(workflow2, mtcars) extract_mold(workflow2)$predictors #> # A tibble: 32 × 10 #> cyl disp hp drat wt qsec vs am gear carb #> #> 1 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 4 108 93 3.85 2.32 18.6 1 1 4 1 #> 4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 5 8 360 175 3.15 3.44 17.0 0 0 3 2 #> 6 6 225 105 2.76 3.46 20.2 1 0 3 1 #> 7 8 360 245 3.21 3.57 15.8 0 0 3 4 #> 8 4 147. 62 3.69 3.19 20 1 0 4 2 #> 9 4 141. 95 3.92 3.15 22.9 1 0 4 2 #> 10 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> # ℹ 22 more rows # Variables can also be added from the result of a call to # `workflow_variables()`, which creates a standalone variables object variables <- workflow_variables(mpg, c(cyl, disp)) workflow3 <- add_variables(workflow, variables = variables) fit(workflow3, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: c(cyl, disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 34.66099 -1.58728 -0.02058 #>"},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment data with predictions — augment.workflow","title":"Augment data with predictions — augment.workflow","text":"generics::augment() method workflow calls augment() underlying parsnip model new_data. x must trained workflow, resulting fitted parsnip model augment() . new_data preprocessed using preprocessor workflow, preprocessed data used generate predictions. final result contain original new_data new columns containing prediction information.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment data with predictions — augment.workflow","text":"","code":"# S3 method for class 'workflow' augment(x, new_data, eval_time = NULL, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment data with predictions — augment.workflow","text":"x workflow new_data data frame predictors eval_time censored regression models, vector time points survival probability estimated. See parsnip::augment.model_fit() details. ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment data with predictions — augment.workflow","text":"new_data new prediction specific columns.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment data with predictions — augment.workflow","text":"","code":"if (rlang::is_installed(\"broom\")) { library(parsnip) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") wf <- workflow() %>% add_model(model) %>% add_formula( Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime ) wf_fit <- fit(wf, attrition) augment(wf_fit, attrition) }"},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Control object for a workflow — control_workflow","title":"Control object for a workflow — control_workflow","text":"control_workflow() holds control parameters workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control object for a workflow — control_workflow","text":"","code":"control_workflow(control_parsnip = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control object for a workflow — control_workflow","text":"control_parsnip parsnip control object. NULL, default control argument constructed parsnip::control_parsnip().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control object for a workflow — control_workflow","text":"control_workflow object tweaking workflow fitting process.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control object for a workflow — control_workflow","text":"","code":"control_workflow() #> "},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements of a workflow — extract-workflow","title":"Extract elements of a workflow — extract-workflow","text":"functions extract various elements workflow object. exist yet, error thrown. extract_preprocessor() returns formula, recipe, variable expressions used preprocessing. extract_spec_parsnip() returns parsnip model specification. extract_fit_parsnip() returns parsnip model fit object. extract_fit_engine() returns engine specific fit embedded within parsnip model fit. example, using parsnip::linear_reg() \"lm\" engine, returns underlying lm object. extract_mold() returns preprocessed \"mold\" object returned hardhat::mold(). contains information preprocessing, including either prepped recipe, formula terms object, variable selectors. extract_recipe() returns recipe. estimated argument specifies whether fitted original recipe returned. extract_parameter_dials() returns single dials parameter object. extract_parameter_set_dials() returns set dials parameter objects. extract_fit_time() returns tibble elapsed fit times. fit times correspond time parsnip engine recipe steps fit (sum summarize = TRUE) include portions elapsed time fit.workflow().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements of a workflow — extract-workflow","text":"","code":"# S3 method for class 'workflow' extract_spec_parsnip(x, ...) # S3 method for class 'workflow' extract_recipe(x, ..., estimated = TRUE) # S3 method for class 'workflow' extract_fit_parsnip(x, ...) # S3 method for class 'workflow' extract_fit_engine(x, ...) # S3 method for class 'workflow' extract_mold(x, ...) # S3 method for class 'workflow' extract_preprocessor(x, ...) # S3 method for class 'workflow' extract_postprocessor(x, estimated = TRUE, ...) # S3 method for class 'workflow' extract_parameter_set_dials(x, ...) # S3 method for class 'workflow' extract_parameter_dials(x, parameter, ...) # S3 method for class 'workflow' extract_fit_time(x, summarize = TRUE, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements of a workflow — extract-workflow","text":"x workflow ... currently used. estimated logical whether original (unfit) recipe fitted recipe returned. argument named. parameter single string parameter ID. summarize logical whether elapsed fit time returned single row multiple rows.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements of a workflow — extract-workflow","text":"extracted value object, x, described description section.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract elements of a workflow — extract-workflow","text":"Extracting underlying engine fit can helpful describing model (via print(), summary(), plot(), etc.) variable importance/explainers. However, users invoke predict() method extracted model. may preprocessing operations workflows executed data prior giving model. Bypassing can lead errors silently generating incorrect predictions. Good: Bad:","code":"workflow_fit %>% predict(new_data) workflow_fit %>% extract_fit_engine() %>% predict(new_data) # or workflow_fit %>% extract_fit_parsnip() %>% predict(new_data)"},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract elements of a workflow — extract-workflow","text":"","code":"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 recipe, formula, or a list holding the # tidyselect expressions identifying the outcomes/predictors extract_preprocessor(recipe_wf) #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Operations #> • Log transformation on: disp extract_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) #> extract_preprocessor(variable_wf) #> $outcomes #> #> expr: ^mpg #> env: 0x55bbc75c7f40 #> #> $predictors #> #> expr: ^c(cyl, disp) #> env: 0x55bbc75c7f40 #> #> attr(,\"class\") #> [1] \"workflow_variables\" # The `spec` is the parsnip spec before it has been fit. # The `fit` is the fitted parsnip model. extract_spec_parsnip(fit_formula_wf) #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> extract_fit_parsnip(fit_formula_wf) #> parsnip model object #> #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> extract_fit_engine(fit_formula_wf) #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # 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. extract_mold(fit_recipe_wf) #> $predictors #> # A tibble: 32 × 2 #> cyl disp #> #> 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 #> # ℹ 22 more rows #> #> $outcomes #> # A tibble: 32 × 1 #> mpg #> #> 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 #> # ℹ 22 more rows #> #> $blueprint #> Recipe blueprint: #> #> # Predictors: 2 #> # Outcomes: 1 #> Intercept: FALSE #> Novel Levels: FALSE #> Composition: tibble #> #> $extras #> $extras$roles #> NULL #> #> # A useful shortcut is to extract the fitted recipe from the workflow extract_recipe(fit_recipe_wf) #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Training information #> Training data contained 32 data points and no incomplete rows. #> #> ── Operations #> • Log transformation on: disp | Trained # That is identical to identical( extract_mold(fit_recipe_wf)$blueprint$recipe, extract_recipe(fit_recipe_wf) ) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit a workflow object — fit-workflow","title":"Fit a workflow object — fit-workflow","text":"Fitting workflow currently involves three main steps: Preprocessing data using formula preprocessor, calling recipes::prep() recipe. Fitting underlying parsnip model using parsnip::fit.model_spec(). Postprocessing predictions model using tailor::tailor().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit a workflow object — fit-workflow","text":"","code":"# S3 method for class 'workflow' fit(object, data, ..., calibration = NULL, control = control_workflow())"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit a workflow object — fit-workflow","text":"object workflow data data frame predictors outcomes use fitting preprocessor model. ... used calibration data frame predictors outcomes use fitting postprocessor. See \"Data Usage\" section add_tailor() information. control control_workflow() object","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit a workflow object — fit-workflow","text":"workflow object, updated fit parsnip model object$fit$fit slot.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Fit a workflow object — fit-workflow","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Fit a workflow object — fit-workflow","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Fit a workflow object — fit-workflow","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit a workflow object — fit-workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) model <- linear_reg() %>% set_engine(\"lm\") base_wf <- workflow() %>% add_model(model) formula_wf <- base_wf %>% add_formula(mpg ~ cyl + log(disp)) fit(formula_wf, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> recipe <- recipe(mpg ~ cyl + disp, mtcars) %>% step_log(disp) recipe_wf <- base_wf %>% add_recipe(recipe) fit(recipe_wf, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> • step_log() #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 67.6674 -0.1755 -8.7971 #>"},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Glance at a workflow model — glance.workflow","title":"Glance at a workflow model — glance.workflow","text":"generics::glance() method workflow calls glance() underlying parsnip model. x must trained workflow, resulting fitted parsnip model glance() .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Glance at a workflow model — glance.workflow","text":"","code":"# S3 method for class 'workflow' glance(x, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Glance at a workflow model — glance.workflow","text":"x workflow ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Glance at a workflow model — glance.workflow","text":"","code":"if (rlang::is_installed(\"broom\")) { library(parsnip) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") wf <- workflow() %>% add_model(model) %>% add_formula( Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime ) # Workflow must be trained to call `glance()` try(glance(wf)) wf_fit <- fit(wf, attrition) glance(wf_fit) }"},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine if a workflow has been trained — is_trained_workflow","title":"Determine if a workflow has been trained — is_trained_workflow","text":"trained workflow one gone fit(), preprocesses underlying data, fits parsnip model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine if a workflow has been trained — is_trained_workflow","text":"","code":"is_trained_workflow(x)"},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine if a workflow has been trained — is_trained_workflow","text":"x workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine if a workflow has been trained — is_trained_workflow","text":"single logical indicating workflow trained .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine if a workflow has been trained — is_trained_workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) rec <- recipe(mpg ~ cyl, mtcars) mod <- linear_reg() mod <- set_engine(mod, \"lm\") wf <- workflow() %>% add_recipe(rec) %>% add_model(mod) # Before any preprocessing or model fitting has been done is_trained_workflow(wf) #> [1] FALSE wf <- fit(wf, mtcars) # After all preprocessing and model fitting is_trained_workflow(wf) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict from a workflow — predict-workflow","title":"Predict from a workflow — predict-workflow","text":"predict() method fit workflow object. nice thing predicting workflow : Preprocess new_data using preprocessing method specified workflow created fit. accomplished using hardhat::forge(), apply formula preprocessing call recipes::bake() recipe supplied. Call parsnip::predict.model_fit() using underlying fit parsnip model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict from a workflow — predict-workflow","text":"","code":"# S3 method for class 'workflow' predict(object, new_data, type = NULL, opts = list(), ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict from a workflow — predict-workflow","text":"object workflow fit fit.workflow() new_data data frame containing new predictors preprocess predict . using recipe preprocessor, call recipes::bake() new_data passing function. type single character value NULL. Possible values \"numeric\", \"class\", \"prob\", \"conf_int\", \"pred_int\", \"quantile\", \"time\", \"hazard\", \"survival\", \"raw\". NULL, predict() choose appropriate value based model's mode. opts list optional arguments underlying predict function used type = \"raw\". list include options model object new data predicted. ... Additional parsnip-related options, depending value type. Arguments underlying model's prediction function passed (use opts argument instead). Possible arguments : interval: type equal \"survival\" \"quantile\", interval estimates added, available? Options \"none\" \"confidence\". level: type equal \"conf_int\", \"pred_int\", \"survival\", parameter tail area intervals (e.g. confidence level confidence intervals). Default value 0.95. std_error: type equal \"conf_int\" \"pred_int\", add standard error fit prediction (scale linear predictors). Default value FALSE. quantile: type equal quantile, quantiles distribution. Default (1:9)/10. eval_time: type equal \"survival\" \"hazard\", time points survival probability hazard estimated.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict from a workflow — predict-workflow","text":"data frame model predictions, many rows new_data .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict from a workflow — predict-workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) training <- mtcars[1:20, ] testing <- mtcars[21:32, ] model <- linear_reg() %>% set_engine(\"lm\") workflow <- workflow() %>% add_model(model) recipe <- recipe(mpg ~ cyl + disp, training) %>% step_log(disp) workflow <- add_recipe(workflow, recipe) fit_workflow <- fit(workflow, training) # This will automatically `bake()` the recipe on `testing`, # applying the log step to `disp`, and then fit the regression. predict(fit_workflow, testing) #> # A tibble: 12 × 1 #> .pred #> #> 1 25.4 #> 2 15.4 #> 3 15.8 #> 4 14.4 #> 5 13.2 #> 6 29.4 #> 7 25.4 #> 8 27.6 #> 9 14.4 #> 10 23.2 #> 11 15.9 #> 12 25.3"},{"path":"https://workflows.tidymodels.org/dev/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. generics fit, required_pkgs hardhat extract_fit_engine, extract_fit_parsnip, extract_fit_time, extract_mold, extract_parameter_dials, extract_parameter_set_dials, extract_postprocessor, extract_preprocessor, extract_recipe, extract_spec_parsnip","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy a workflow — tidy.workflow","title":"Tidy a workflow — tidy.workflow","text":"generics::tidy() method workflow calls tidy() either underlying parsnip model recipe, depending value . x must fitted workflow, resulting fitted parsnip model prepped recipe want tidy.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy a workflow — tidy.workflow","text":"","code":"# S3 method for class 'workflow' tidy(x, what = \"model\", ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy a workflow — tidy.workflow","text":"x workflow single string. Either \"model\" \"recipe\" select part workflow tidy. Defaults tidying model. ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tidy a workflow — tidy.workflow","text":"tidy unprepped recipe, use extract_preprocessor() tidy() directly.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":null,"dir":"Reference","previous_headings":"","what":"Butcher methods for a workflow — workflow-butcher","title":"Butcher methods for a workflow — workflow-butcher","text":"methods allow use butcher package reduce size workflow. calling butcher::butcher() workflow, guarantee still able predict() workflow. functions may work expected.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Butcher methods for a workflow — workflow-butcher","text":"","code":"axe_call.workflow(x, verbose = FALSE, ...) axe_ctrl.workflow(x, verbose = FALSE, ...) axe_data.workflow(x, verbose = FALSE, ...) axe_env.workflow(x, verbose = FALSE, ...) axe_fitted.workflow(x, verbose = FALSE, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Butcher methods for a workflow — workflow-butcher","text":"x workflow. verbose information printed much memory freed butchering? ... Extra arguments possibly used underlying methods.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements of a workflow — workflow-extractors","title":"Extract elements of a workflow — workflow-extractors","text":"Please use extract_*() functions instead (e.g. extract_mold()). functions extract various elements workflow object. exist yet, error thrown. pull_workflow_preprocessor() returns formula, recipe, variable expressions used preprocessing. pull_workflow_spec() returns parsnip model specification. pull_workflow_fit() returns parsnip model fit. pull_workflow_mold() returns preprocessed \"mold\" object returned hardhat::mold(). contains information preprocessing, including either prepped recipe formula terms object. pull_workflow_prepped_recipe() returns prepped recipe. extracted mold object returned pull_workflow_mold().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements of a workflow — workflow-extractors","text":"","code":"pull_workflow_preprocessor(x) pull_workflow_spec(x) pull_workflow_fit(x) pull_workflow_mold(x) pull_workflow_prepped_recipe(x)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements of a workflow — workflow-extractors","text":"x workflow","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements of a workflow — workflow-extractors","text":"extracted value workflow, x, described description section.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract elements of a workflow — workflow-extractors","text":"","code":"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) #> Warning: `pull_workflow_preprocessor()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_preprocessor()` instead. #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Operations #> • Log transformation on: disp pull_workflow_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) #> pull_workflow_preprocessor(variable_wf) #> $outcomes #> #> expr: ^mpg #> env: 0x55bbcc9fe268 #> #> $predictors #> #> expr: ^c(cyl, disp) #> env: 0x55bbcc9fe268 #> #> attr(,\"class\") #> [1] \"workflow_variables\" # The `spec` is the parsnip spec before it has been fit. # The `fit` is the fit parsnip model. pull_workflow_spec(fit_formula_wf) #> Warning: `pull_workflow_spec()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_spec_parsnip()` instead. #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> pull_workflow_fit(fit_formula_wf) #> Warning: `pull_workflow_fit()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_fit_parsnip()` instead. #> parsnip model object #> #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # 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) #> Warning: `pull_workflow_mold()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_mold()` instead. #> $predictors #> # A tibble: 32 × 2 #> cyl disp #> #> 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 #> # ℹ 22 more rows #> #> $outcomes #> # A tibble: 32 × 1 #> mpg #> #> 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 #> # ℹ 22 more rows #> #> $blueprint #> Recipe blueprint: #> #> # Predictors: 2 #> # Outcomes: 1 #> Intercept: FALSE #> Novel Levels: FALSE #> Composition: tibble #> #> $extras #> $extras$roles #> NULL #> #> # A useful shortcut is to extract the prepped recipe from the workflow pull_workflow_prepped_recipe(fit_recipe_wf) #> Warning: `pull_workflow_prepped_recipe()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_recipe()` instead. #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Training information #> Training data contained 32 data points and no incomplete rows. #> #> ── Operations #> • Log transformation on: disp | Trained # That is identical to identical( pull_workflow_mold(fit_recipe_wf)$blueprint$recipe, pull_workflow_prepped_recipe(fit_recipe_wf) ) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a workflow — workflow","title":"Create a workflow — workflow","text":"workflow container object aggregates information required fit predict model. information might recipe used preprocessing, specified add_recipe(), model specification fit, specified add_model(), tailor used postprocessing, specified add_tailor(). preprocessor spec arguments allow add components workflow quickly, without go add_*() functions, add_recipe() add_model(). However, need control optional arguments functions, blueprint model formula, use add_*() functions directly instead.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a workflow — workflow","text":"","code":"workflow(preprocessor = NULL, spec = NULL, postprocessor = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a workflow — workflow","text":"preprocessor optional preprocessor add workflow. One : formula, passed add_formula(). recipe, passed add_recipe(). workflow_variables() object, passed add_variables(). spec optional parsnip model specification add workflow. Passed add_model(). postprocessor optional tailor::tailor() defining post-processing steps add workflow. Passed add_tailor().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a workflow — workflow","text":"new workflow object.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Create a workflow — workflow","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Create a workflow — workflow","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Create a workflow — workflow","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a workflow — workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") formula <- Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime wf_formula <- workflow(formula, model) fit(wf_formula, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) BusinessTravelTravel_Frequently #> -2.82571 1.29473 #> BusinessTravelTravel_Rarely YearsSinceLastPromotion #> 0.64727 -0.03092 #> OverTimeYes #> 1.31904 #> #> Degrees of Freedom: 1469 Total (i.e. Null); 1465 Residual #> Null Deviance:\t 1299 #> Residual Deviance: 1194 \tAIC: 1204 recipe <- recipe(Attrition ~ ., attrition) %>% step_dummy(all_nominal(), -Attrition) %>% step_corr(all_predictors(), threshold = 0.8) wf_recipe <- workflow(recipe, model) fit(wf_recipe, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 2 Recipe Steps #> #> • step_dummy() #> • step_corr() #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) Age #> -2.535e+00 -3.131e-02 #> DailyRate DistanceFromHome #> -3.126e-04 4.927e-02 #> HourlyRate MonthlyIncome #> 2.762e-03 1.127e-06 #> MonthlyRate NumCompaniesWorked #> 1.663e-06 1.956e-01 #> PercentSalaryHike StockOptionLevel #> -2.495e-02 -1.968e-01 #> TotalWorkingYears TrainingTimesLastYear #> -6.820e-02 -1.863e-01 #> YearsAtCompany YearsInCurrentRole #> 8.916e-02 -1.371e-01 #> YearsSinceLastPromotion YearsWithCurrManager #> 1.849e-01 -1.516e-01 #> BusinessTravel_Travel_Frequently BusinessTravel_Travel_Rarely #> 1.940e+00 1.080e+00 #> Education_1 Education_2 #> -1.391e-01 -2.753e-01 #> Education_3 Education_4 #> -7.324e-02 3.858e-02 #> EducationField_Life_Sciences EducationField_Marketing #> -6.939e-01 -2.212e-01 #> EducationField_Medical EducationField_Other #> -7.210e-01 -6.755e-01 #> EducationField_Technical_Degree EnvironmentSatisfaction_1 #> 2.936e-01 -9.501e-01 #> EnvironmentSatisfaction_2 EnvironmentSatisfaction_3 #> 4.383e-01 -2.491e-01 #> Gender_Male JobInvolvement_1 #> 4.243e-01 -1.474e+00 #> JobInvolvement_2 JobInvolvement_3 #> 2.297e-01 -2.855e-01 #> JobRole_Human_Resources JobRole_Laboratory_Technician #> 1.441e+00 1.549e+00 #> JobRole_Manager JobRole_Manufacturing_Director #> 1.900e-01 3.726e-01 #> JobRole_Research_Director JobRole_Research_Scientist #> -9.581e-01 6.055e-01 #> JobRole_Sales_Executive JobRole_Sales_Representative #> 1.056e+00 2.149e+00 #> JobSatisfaction_1 JobSatisfaction_2 #> -9.446e-01 -8.929e-03 #> JobSatisfaction_3 MaritalStatus_Married #> -2.860e-01 3.135e-01 #> #> ... #> and 14 more lines. variables <- workflow_variables( Attrition, c(BusinessTravel, YearsSinceLastPromotion, OverTime) ) wf_variables <- workflow(variables, model) fit(wf_variables, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: Attrition #> Predictors: c(BusinessTravel, YearsSinceLastPromotion, OverTime) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) BusinessTravelTravel_Frequently #> -2.82571 1.29473 #> BusinessTravelTravel_Rarely YearsSinceLastPromotion #> 0.64727 -0.03092 #> OverTimeYes #> 1.31904 #> #> Degrees of Freedom: 1469 Total (i.e. Null); 1465 Residual #> Null Deviance:\t 1299 #> Residual Deviance: 1194 \tAIC: 1204"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal workflow functions — .workflow_includes_calibration","title":"Internal workflow functions — .workflow_includes_calibration","text":".fit_pre(), .fit_model(), .fit_finalize() internal workflow functions partially fitting workflow object. exported usage tuning package, tune, general user never need worry .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal workflow functions — .workflow_includes_calibration","text":"","code":".workflow_includes_calibration(workflow) .fit_pre(workflow, data) .fit_model(workflow, control) .fit_post(workflow, data) .fit_finalize(workflow)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Internal workflow functions — .workflow_includes_calibration","text":"workflow workflow .fit_pre(), fresh workflow. .fit_model(), workflow already trained .fit_pre(). .fit_finalize(), workflow .fit_pre() .fit_model(). data data frame predictors outcomes use fitting workflow control control_workflow() object","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Internal workflow functions — .workflow_includes_calibration","text":"","code":"library(parsnip) library(recipes) library(magrittr) model <- linear_reg() %>% set_engine(\"lm\") wf_unfit <- workflow() %>% add_model(model) %>% add_formula(mpg ~ cyl + log(disp)) wf_fit_pre <- .fit_pre(wf_unfit, mtcars) wf_fit_model <- .fit_model(wf_fit_pre, control_workflow()) wf_fit <- .fit_finalize(wf_fit_model) # Notice that fitting through the model doesn't mark the # workflow as being \"trained\" wf_fit_model #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # Finalizing the workflow marks it as \"trained\" wf_fit #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # Which allows you to predict from it try(predict(wf_fit_model, mtcars)) #> Error in predict(wf_fit_model, mtcars) : #> Can't predict on an untrained workflow. #> ℹ Do you need to call `fit()`? predict(wf_fit, mtcars) #> # A tibble: 32 × 1 #> .pred #> #> 1 22.0 #> 2 22.0 #> 3 25.8 #> 4 17.8 #> 5 14.5 #> 6 19.0 #> 7 14.5 #> 8 23.1 #> 9 23.4 #> 10 21.6 #> # ℹ 22 more rows"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-package.html","id":null,"dir":"Reference","previous_headings":"","what":"workflows: Modeling Workflows — workflows-package","title":"workflows: Modeling Workflows — workflows-package","text":"Managing 'parsnip' model preprocessor, model formula recipe 'recipes', can often challenging. goal 'workflows' streamline process bundling model alongside preprocessor, within object.","code":""},{"path":[]},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"workflows: Modeling Workflows — workflows-package","text":"Maintainer: Simon Couch simon.couch@posit.co (ORCID) Authors: Davis Vaughan davis@posit.co contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-development-version","dir":"Changelog","previous_headings":"","what":"workflows (development version)","title":"workflows (development version)","text":"Package warnings errors transitioned use cli instead rlang (#241). add_variables() reference added stages vignette (@brshallo, #190). New extract_fit_time() method added return time took train workflow (#191). fit() can now take dgCMatrix sparse tibbles data values add_recipe() add_variables() used (#245, #258). predict() can now take dgCMatrix sparse tibble input new_data argument (#261).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-114","dir":"Changelog","previous_headings":"","what":"workflows 1.1.4","title":"workflows 1.1.4","text":"CRAN release: 2024-02-19 augment.workflow() previously never returned .resid column, method now return residuals conditions augment.model_fit() (#201). augment.workflow() gained eval_time argument, enabling augmenting censored regression models (#200, #213). prediction columns now appended LHS rather RHS new_data augment.workflow(), following analogous changes parsnip (#200). pull_*() functions soft-deprecated workflows v0.2.3 now warn every usage (#198). add_recipe() now error informatively supplied trained recipe (#179).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-113","dir":"Changelog","previous_headings":"","what":"workflows 1.1.3","title":"workflows 1.1.3","text":"CRAN release: 2023-02-22 workflows methods generics::tune_args() generics::tunable() now registered unconditionally (#192).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-112","dir":"Changelog","previous_headings":"","what":"workflows 1.1.2","title":"workflows 1.1.2","text":"CRAN release: 2022-11-16 Tightens integration parsnip’s machinery checking needed parsnip extension packages loaded. add_model() now error model specification supplied requires missing extension package (#184). Introduces support unsupervised model specifications via modelenv package (#180).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-110","dir":"Changelog","previous_headings":"","what":"workflows 1.1.0","title":"workflows 1.1.0","text":"CRAN release: 2022-09-26 Simon Couch now maintainer (#170). add_model() now errors try add model specification contains unknown mode. breaking change, previously cases successfully “guess” mode. change brings workflows line parsnip::fit() parsnip::fit_xy() (#160, tidymodels/parsnip#801). broom::augment() now works correctly edge case supplied hardhat blueprint composition set either \"matrix\" \"dgCMatrix\" (#148). butcher::axe_fitted() now axes recipe preprocessor stored inside workflow, reduce size template data frame stored recipe (#147). add_formula() longer silently ignores offsets supplied offset(). Instead, now errors fit() time message encourages use model formula add_model(formula = ) instead (#162).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-100","dir":"Changelog","previous_headings":"","what":"workflows 1.0.0","title":"workflows 1.0.0","text":"CRAN release: 2022-07-05 New add_case_weights(), update_case_weights(), remove_case_weights() specifying column use case weights passed underlying parsnip model (#118). R >=3.4.0 now required, line rest tidyverse.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-026","dir":"Changelog","previous_headings":"","what":"workflows 0.2.6","title":"workflows 0.2.6","text":"CRAN release: 2022-03-18 Fixed tests relied incorrect assumption version tune installed.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-025","dir":"Changelog","previous_headings":"","what":"workflows 0.2.5","title":"workflows 0.2.5","text":"CRAN release: 2022-03-16 Improved error message workflow_variables() either outcomes predictors missing (#144). Removed ellipsis dependency favor equivalent functions rlang. New extract_parameter_set_dials() extract_parameter_dials() methods extract parameter sets single parameters workflow objects.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-024","dir":"Changelog","previous_headings":"","what":"workflows 0.2.4","title":"workflows 0.2.4","text":"CRAN release: 2021-10-12 add_model() update_model() now use ... separate required arguments optional arguments, forcing optional arguments named. change made make easier us extend functions new arguments future. workflows method generics::required_pkgs() now registered unconditionally (#121). Internally cleaned remaining usage soft-deprecated pull_*() functions.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-023","dir":"Changelog","previous_headings":"","what":"workflows 0.2.3","title":"workflows 0.2.3","text":"CRAN release: 2021-07-15 workflow() gained new preprocessor spec arguments adding preprocessor (recipe formula) parsnip model specification directly workflow upon creation. many cases, can reduce lines code required construct complete workflow (#108). New extract_*() functions added supersede existing pull_*() functions. part larger move across tidymodels packages towards family generic extract_*() functions. pull_*() functions soft-deprecated, eventually removed (#106).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-022","dir":"Changelog","previous_headings":"","what":"workflows 0.2.2","title":"workflows 0.2.2","text":"CRAN release: 2021-03-10 add_variables() now allows specifying bundle model terms add_variables(variables = ), supplying pre-created set variables new workflow_variables() helper. useful supplying set variables programmatically (#92). New is_trained_workflow() determining workflow already trained call fit() (#91). fit() now errors immediately control created control_workflow() (#89). Added broom::augment() broom::glance() methods trained workflow objects (#76). Added support butchering workflow using butcher::butcher(). Updated testthat 3.0.0.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-021","dir":"Changelog","previous_headings":"","what":"workflows 0.2.1","title":"workflows 0.2.1","text":"CRAN release: 2020-10-08 New .fit_finalize() internal usage tune package.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-020","dir":"Changelog","previous_headings":"","what":"workflows 0.2.0","title":"workflows 0.2.0","text":"CRAN release: 2020-09-15 New add_variables() specifying model terms using tidyselect expressions extra preprocessing. example: One benefit specifying terms way formula method avoid preprocessing model.matrix(), might strip class predictor columns (Date columns) (#34).","code":"wf <- workflow() %>% add_variables(y, c(var1, start_with(\"x_\"))) %>% add_model(spec_lm)"},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-013","dir":"Changelog","previous_headings":"","what":"workflows 0.1.3","title":"workflows 0.1.3","text":"CRAN release: 2020-08-10 test updated reflect change parsnip 0.1.3 regarding intercept columns removed prediction (#65).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-012","dir":"Changelog","previous_headings":"","what":"workflows 0.1.2","title":"workflows 0.1.2","text":"CRAN release: 2020-07-07 using formula preprocessor add_formula(), workflows now uses model-specific information parsnip decide whether expand factors via dummy encoding (n - 1 levels), one-hot encoding (n levels), expansion . result intuitive behavior working models don’t require dummy variables. example, parsnip rand_forest() model used ranger engine, dummy variables created, ranger can handle factors directly (#51, #53).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-011","dir":"Changelog","previous_headings":"","what":"workflows 0.1.1","title":"workflows 0.1.1","text":"CRAN release: 2020-03-17 hardhat’s minimum required version bumped 0.1.2, contains important fix recipes prepped default.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-010","dir":"Changelog","previous_headings":"","what":"workflows 0.1.0","title":"workflows 0.1.0","text":"CRAN release: 2019-12-30 Added NEWS.md file track changes package.","code":""}] +[{"path":[]},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://workflows.tidymodels.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tidymodels","title":"Contributing to tidymodels","text":"detailed information contributing tidymodels packages, see development contributing guide.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Contributing to tidymodels","text":"Typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES ✅: edit roxygen comment .R file R/ directory. 🚫: edit .Rd file man/ directory. use roxygen2, Markdown syntax, documentation.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"code","dir":"","previous_headings":"","what":"Code","title":"Contributing to tidymodels","text":"submit 🎯 pull request tidymodels package, always file issue confirm tidymodels team agrees idea happy basic proposal. tidymodels packages work together. package contains unit tests, integration tests tests using packages contained extratests. recommend create Git branch pull request (PR). Look build status making changes. README contains badges continuous integration services used package. New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s). use testthat. Contributions test cases included easier accept. contribution spans use one package, consider building extratests changes check breakages /adding new tests . Let us know PR ran extra tests.","code":""},{"path":"https://workflows.tidymodels.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"Code","what":"Code of Conduct","title":"Contributing to tidymodels","text":"project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://workflows.tidymodels.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 workflows authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"current-state","dir":"","previous_headings":"","what":"Current state","title":"NA","text":"Workflows stable. currently supports implemented model types tidymodels, including censored modeltime. Often looks like model type supported typical workflows model, user can supply “model formula” gets passed directly parsnip workaround (.e. add_model(formula = )). general model workflows split 3 stages: pre, fit, post. pre controls preprocessing, divided “actions”. formula, recipes, variables actions correspond 3 preprocessor types hardhat. can use one per workflow. case weights action controls case weights extracted data passed parsnip model. Internally force action run preprocessor actions. fit controls model fit. 1 “model” action , anticipate actions stage workflow. post controls postprocessing. 1 “tailor” action , though may others future. workflow specified, fit() called fit “actions”. loops actions workflow, calls fit() actions well (S3 methods fit() action). similar recipes, step prep() method. Keep mind people save fitted workflows reload prediction, considerations backwards compatibility. time add new feature, change existing one, need keep mind whether old workflows saved disk continue run new version workflows. Historically problem hardhat, backwards compatibility issues seem like hardhat problem, suggest adding backwards compatibility tests hardhat directly instead.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"known-issues","dir":"","previous_headings":"","what":"Known issues","title":"NA","text":"think still don’t support parsnip::multi_predict(). time remember seeing clear way integrate , maybe landscape changed since https://github.com/tidymodels/workflows/issues/4.","code":""},{"path":"https://workflows.tidymodels.org/dev/MAINTENANCE.html","id":"future-directions","dir":"","previous_headings":"","what":"Future directions","title":"NA","text":"known feature want add workflows support postprocessing. mentioned , requires tooling probably package, along tight integration tune (likely need 3rd inner loop control tuning postprocessing options).","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"introduction","dir":"Articles > Extras","previous_headings":"","what":"Introduction","title":"Getting Started","text":"bivariate data set, two predictors can used differentiate two classes outcome. three partitions original data: training (n = 1009), validation (n = 300), testing (n = 710). work training set , use validation set compare models development process, use test set think good algorithm making predictions. training set: predictors positive values distributions right-skewed. seems separation classes, variables used together. example, predictors visualized individually, little evidence separation classes. first plot , separation appears happen linearly, straight, diagonal boundary might well. use glm() directly create logistic regression, use tidymodels infrastructure start making parsnip model object. data analysis involve looking different approaches representing two predictors high-quality model. ’ll walk though thought process analysis go. emulate data analysis projects happen: initial approach taken potential steps attempted make improvements. pre-defined blueprint process R4DS diagram summarizes process nicely. Since going try different combinations feature engineering models, workflows really useful since can one object contains operations. helps organize work instead different objects workspace , point, used pairs.","code":"library(modeldata) # This gives us access to the 3 partitions: # - `bivariate_train`: Training set # - `bivariate_val`: Validation set # - `bivariate_test`: Test set data(\"bivariate\") library(workflows) library(ggplot2) library(dplyr) ggplot(bivariate_train, aes(x = A, y = B, col = Class)) + geom_point(alpha = .3) + coord_equal(ratio = 20) library(tidyr) bivariate_train %>% pivot_longer(cols = c(A, B), names_to = \"predictor\") %>% ggplot(aes(x = Class, y = value)) + geom_boxplot() + facet_wrap(~predictor, scales = \"free_y\") + scale_y_log10() library(parsnip) logit_mod <- logistic_reg() %>% set_engine(\"glm\")"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"a-first-set-of-models","dir":"Articles > Extras","previous_headings":"","what":"A first set of models","title":"Getting Started","text":"obvious place start adding predictors -model: evaluate model, ROC curve computed along corresponding AUC. seems reasonable. One potential issue two predictors high degree correlation 0.848, might cause instability model. Since two correlated predictors skewed distributions strictly positive values, might intuitive use ratio instead pair. ’ll try next recycling initial workflow just adding different formula: original analysis shows slight edge, two models probably within experimental noise one another.","code":"# Create a workflow with just the model. We will add to this as we go. glm_workflow <- workflow() %>% add_model(logit_mod) simple_glm <- glm_workflow %>% # Add both predictors in add_formula(Class ~ .) %>% # Fit the model: fit(data = bivariate_train) library(yardstick) simple_glm_probs <- predict(simple_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) simple_glm_roc <- simple_glm_probs %>% roc_curve(Class, .pred_One) simple_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.773 autoplot(simple_glm_roc) ratio_glm <- glm_workflow %>% add_formula(Class ~ I(A/B)) %>% fit(data = bivariate_train) ratio_glm_probs <- predict(ratio_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) ratio_glm_roc <- ratio_glm_probs %>% roc_curve(Class, .pred_One) ratio_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.765 autoplot(simple_glm_roc) + geom_path( data = ratio_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#FDE725FF\" )"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"more-complex-feature-engineering","dir":"Articles > Extras","previous_headings":"","what":"More complex feature engineering","title":"Getting Started","text":"Instead combining two predictors, help model resolve skewness variables? test theory, one option use Box-Cox transformation predictor individually see recommends nonlinear transformation. transformation can encode variety different functions including log transform, square root, inverse, fractional transformations -. easily done via formula interface, recipe used. recipe list sequential data processing steps conducted data used model. example, use Box-Cox method, simple recipe : Creating recipe makes object instructions; carry instructions (e.g. estimate transformation parameter). actually execute recipe, add workflow add_recipe() call fit(). Fitting workflow evaluates model recipe. potential, slight, improvement. Box-Cox procedure recommended transformations pretty close inverse. model creates class boundary data: correlation original data. might help model de-correlate , standard technique principal component analysis. recipe step can added conduct PCA return score values. scores, instead original predictors, can used model. PCA chases variability, important normalize two predictors units. Traditionally, column centered scaled. reason, step used prior PCA normalizes two predictors. results almost identical transformed model.","code":"library(recipes) trans_recipe <- recipe(Class ~ ., data = bivariate_train) %>% step_BoxCox(all_predictors()) trans_glm <- glm_workflow %>% add_recipe(trans_recipe) %>% fit(data = bivariate_train) trans_glm_probs <- predict(trans_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) trans_glm_roc <- trans_glm_probs %>% roc_curve(Class, .pred_One) trans_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.815 autoplot(simple_glm_roc) + geom_path( data = ratio_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#FDE725FF\" ) + geom_path( data = trans_glm_roc, aes(x = 1 - specificity, y = sensitivity), col = \"#21908CFF\" ) ggplot(bivariate_train, aes(x = 1/A, y = 1/B, col = Class)) + geom_point(alpha = .3) + coord_equal(ratio = 1/12) pca_recipe <- trans_recipe %>% step_normalize(A, B) %>% step_pca(A, B, num_comp = 2) pca_glm <- glm_workflow %>% add_recipe(pca_recipe) %>% fit(data = bivariate_train) pca_glm_probs <- predict(pca_glm, bivariate_val, type = \"prob\") %>% bind_cols(bivariate_val) pca_glm_roc <- pca_glm_probs %>% roc_curve(Class, .pred_One) pca_glm_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.815"},{"path":"https://workflows.tidymodels.org/dev/articles/extras/getting-started.html","id":"the-test-set","dir":"Articles > Extras","previous_headings":"","what":"The test set","title":"Getting Started","text":"Based results, model logistic regression model inverse terms probably best bet. Using test set:","code":"test_probs <- predict(trans_glm, bivariate_test, type = \"prob\") %>% bind_cols(bivariate_test) test_roc <- test_probs %>% roc_curve(Class, .pred_One) # A little more optimistic than the validation set test_probs %>% roc_auc(Class, .pred_One) #> # A tibble: 1 × 3 #> .metric .estimator .estimate #> #> 1 roc_auc binary 0.862 autoplot(test_roc)"},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"pre-processing","dir":"Articles","previous_headings":"","what":"Pre-processing","title":"Workflow Stages","text":"three elements allowed pre-processing : standard model formula via add_formula(). tidyselect interface via add_variables() strictly preserves class columns. recipe object via add_recipe(). can use one .","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"model-fitting","dir":"Articles","previous_headings":"","what":"Model Fitting","title":"Workflow Stages","text":"parsnip model specifications option , specified via add_model(). using preprocessor, may need additional formula special model terms (e.g. mixed models generalized linear models). cases, specify formula using add_model()’s formula argument, passed underlying model fit() called.","code":""},{"path":"https://workflows.tidymodels.org/dev/articles/stages.html","id":"post-processing","dir":"Articles","previous_headings":"","what":"Post-processing","title":"Workflow Stages","text":"tailor post-processors option , specified via add_tailor(). examples post-processing model predictions include adding probability threshold two-class problems, calibration probability estimates, truncating possible range predictions, .","code":""},{"path":"https://workflows.tidymodels.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Davis Vaughan. Author. Simon Couch. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://workflows.tidymodels.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Vaughan D, Couch S (2024). workflows: Modeling Workflows. R package version 1.1.4.9000, https://workflows.tidymodels.org, https://github.com/tidymodels/workflows.","code":"@Manual{, title = {workflows: Modeling Workflows}, author = {Davis Vaughan and Simon Couch}, year = {2024}, note = {R package version 1.1.4.9000, https://workflows.tidymodels.org}, url = {https://github.com/tidymodels/workflows}, }"},{"path":[]},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"what-is-a-workflow","dir":"","previous_headings":"","what":"What is a workflow?","title":"Modeling Workflows","text":"workflow object can bundle together pre-processing, modeling, post-processing requests. example, recipe parsnip model, can combined workflow. advantages : don’t keep track separate objects workspace. recipe prepping, model fitting, postprocessor estimation (may include data splitting) can executed using single call fit(). custom tuning parameter settings, can defined using simpler interface combined tune.","code":""},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Modeling Workflows","text":"can install workflows CRAN : can install development version GitHub :","code":"install.packages(\"workflows\") # install.packages(\"pak\") pak::pak(\"tidymodels/workflows\")"},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Modeling Workflows","text":"Suppose modeling data cars. Say…fuel efficiency 32 cars. know relationship engine displacement miles-per-gallon nonlinear, like model spline adding Bayesian linear regression model. might recipe specify spline: model object: use , generally run: can’t predict new samples using bayes_lm_fit without prepped version spline_cars around. also might models recipes workspace. might lead getting mixed-forgetting save model/recipe pair interested . workflows makes easier combining objects together: Now can prepare recipe estimate model via single call fit(): can alter existing workflows using update_recipe() / update_model() remove_recipe() / remove_model().","code":"library(recipes) library(parsnip) library(workflows) spline_cars <- recipe(mpg ~ ., data = mtcars) %>% step_ns(disp, deg_free = 10) bayes_lm <- linear_reg() %>% set_engine(\"stan\") spline_cars_prepped <- prep(spline_cars, mtcars) bayes_lm_fit <- fit(bayes_lm, mpg ~ ., data = juice(spline_cars_prepped)) car_wflow <- workflow() %>% add_recipe(spline_cars) %>% add_model(bayes_lm) car_wflow_fit <- fit(car_wflow, data = mtcars)"},{"path":"https://workflows.tidymodels.org/dev/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Modeling Workflows","text":"project released Contributor Code Conduct. contributing project, agree abide terms. questions discussions tidymodels packages, modeling, machine learning, please post Posit Community. think encountered bug, please submit issue. Either way, learn create share reprex (minimal, reproducible example), clearly communicate code. Check details contributing guidelines tidymodels packages get help.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":null,"dir":"Reference","previous_headings":"","what":"Add case weights to a workflow — add_case_weights","title":"Add case weights to a workflow — add_case_weights","text":"family functions revolves around selecting column data use case weights. column must one allowed case weight types, hardhat::frequency_weights() hardhat::importance_weights(). Specifically, must return TRUE hardhat::is_case_weights(). underlying model decide whether type case weights supplied applicable . add_case_weights() specifies column interpreted case weights model. column must present data supplied fit(). remove_case_weights() removes case weights. Additionally, model already fit, fit removed. update_case_weights() first removes case weights, replaces new ones.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add case weights to a workflow — add_case_weights","text":"","code":"add_case_weights(x, col) remove_case_weights(x) update_case_weights(x, col)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add case weights to a workflow — add_case_weights","text":"x workflow col single unquoted column name specifying case weights model. must classed case weights column, determined hardhat::is_case_weights().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add case weights to a workflow — add_case_weights","text":"formula variable preprocessors, case weights col removed data preprocessor evaluated. allows use formulas like y ~ . tidyselection like everything() without fear accidentally selecting case weights column. recipe preprocessors, case weights col removed passed along recipe. Typically, recipe include steps can utilize case weights.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_case_weights.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add case weights to a workflow — add_case_weights","text":"","code":"library(parsnip) library(magrittr) library(hardhat) mtcars2 <- mtcars mtcars2$gear <- frequency_weights(mtcars2$gear) spec <- linear_reg() %>% set_engine(\"lm\") wf <- workflow() %>% add_case_weights(gear) %>% add_formula(mpg ~ .) %>% add_model(spec) wf <- fit(wf, mtcars2) # Notice that the case weights (gear) aren't included in the predictors extract_mold(wf)$predictors #> # A tibble: 32 × 10 #> `(Intercept)` cyl disp hp drat wt qsec vs am carb #> #> 1 1 6 160 110 3.9 2.62 16.5 0 1 4 #> 2 1 6 160 110 3.9 2.88 17.0 0 1 4 #> 3 1 4 108 93 3.85 2.32 18.6 1 1 1 #> 4 1 6 258 110 3.08 3.22 19.4 1 0 1 #> 5 1 8 360 175 3.15 3.44 17.0 0 0 2 #> 6 1 6 225 105 2.76 3.46 20.2 1 0 1 #> 7 1 8 360 245 3.21 3.57 15.8 0 0 4 #> 8 1 4 147. 62 3.69 3.19 20 1 0 2 #> 9 1 4 141. 95 3.92 3.15 22.9 1 0 2 #> 10 1 6 168. 123 3.92 3.44 18.3 1 0 4 #> # ℹ 22 more rows # Strip them out of the workflow, which also resets the model remove_case_weights(wf) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #>"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":null,"dir":"Reference","previous_headings":"","what":"Add formula terms to a workflow — add_formula","title":"Add formula terms to a workflow — add_formula","text":"add_formula() specifies terms model usage formula. remove_formula() removes formula well downstream objects might get created formula used preprocessing, terms. Additionally, model already fit, fit removed. update_formula() first removes formula, replaces previous formula new one. model already fit based formula need refit.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add formula terms to a workflow — add_formula","text":"","code":"add_formula(x, formula, ..., blueprint = NULL) remove_formula(x) update_formula(x, formula, ..., blueprint = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add formula terms to a workflow — add_formula","text":"x workflow formula formula specifying terms model. advised preprocessing formula, instead use recipe required. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_formula_blueprint() used passed arguments best align model present workflow. Note preprocessing done separate preprocessing might done underlying model. example, blueprint indicators = \"none\" specified, dummy variables created hardhat, underlying model requires formula interface internally uses stats::model.matrix(), factors still expanded dummy variables model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add formula terms to a workflow — add_formula","text":"x, updated either new removed formula preprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add formula terms to a workflow — add_formula","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"formula-handling","dir":"Reference","previous_headings":"","what":"Formula Handling","title":"Add formula terms to a workflow — add_formula","text":"Note , different models, formula given add_formula() might handled different ways, depending parsnip model used. example, random forest model fit using ranger convert factor predictors binary indicator variables. consistent ranger::ranger() , inconsistent stats::model.matrix() . documentation parsnip models provides details data given formula encoded model diverge standard model.matrix() methodology. goal consistent underlying model package works.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"how-is-this-formula-used-","dir":"Reference","previous_headings":"","what":"How is this formula used?","title":"Add formula terms to a workflow — add_formula","text":"demonstrate, example uses lm() fit model. formula given add_formula() used create model matrix passed lm() simple formula body_mass_g ~ .: can affect results analyzed. example, get sequential hypothesis tests, individual term tested:","code":"library(parsnip) library(workflows) library(magrittr) library(modeldata) library(hardhat) data(penguins) lm_mod <- linear_reg() %>% set_engine(\"lm\") lm_wflow <- workflow() %>% add_model(lm_mod) pre_encoded <- lm_wflow %>% add_formula(body_mass_g ~ species + island + bill_depth_mm) %>% fit(data = penguins) pre_encoded_parsnip_fit <- pre_encoded %>% extract_fit_parsnip() pre_encoded_fit <- pre_encoded_parsnip_fit$fit # The `lm()` formula is *not* the same as the `add_formula()` formula: pre_encoded_fit ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) speciesChinstrap speciesGentoo ## -1009.943 1.328 2236.865 ## islandDream islandTorgersen bill_depth_mm ## 9.221 -18.433 256.913 anova(pre_encoded_fit) ## Analysis of Variance Table ## ## Response: ..y ## Df Sum Sq Mean Sq F value Pr(>F) ## speciesChinstrap 1 18642821 18642821 141.1482 <2e-16 *** ## speciesGentoo 1 128221393 128221393 970.7875 <2e-16 *** ## islandDream 1 13399 13399 0.1014 0.7503 ## islandTorgersen 1 255 255 0.0019 0.9650 ## bill_depth_mm 1 28051023 28051023 212.3794 <2e-16 *** ## Residuals 336 44378805 132080 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"overriding-the-default-encodings","dir":"Reference","previous_headings":"","what":"Overriding the default encodings","title":"Add formula terms to a workflow — add_formula","text":"Users can override model-specific encodings using hardhat blueprint. blueprint can specify factors encoded whether intercepts included. example, use formula like data passed model untouched: looks , raw columns given lm() function created dummy variables. , sequential ANOVA tests groups parameters get column-level p-values:","code":"minimal <- default_formula_blueprint(indicators = \"none\", intercept = FALSE) un_encoded <- lm_wflow %>% add_formula( body_mass_g ~ species + island + bill_depth_mm, blueprint = minimal ) %>% fit(data = penguins) un_encoded_parsnip_fit <- un_encoded %>% extract_fit_parsnip() un_encoded_fit <- un_encoded_parsnip_fit$fit un_encoded_fit ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) bill_depth_mm speciesChinstrap ## -1009.943 256.913 1.328 ## speciesGentoo islandDream islandTorgersen ## 2236.865 9.221 -18.433 anova(un_encoded_fit) ## Analysis of Variance Table ## ## Response: ..y ## Df Sum Sq Mean Sq F value Pr(>F) ## bill_depth_mm 1 48840779 48840779 369.782 <2e-16 *** ## species 2 126067249 63033624 477.239 <2e-16 *** ## island 2 20864 10432 0.079 0.9241 ## Residuals 336 44378805 132080 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"overriding-the-default-model-formula","dir":"Reference","previous_headings":"","what":"Overriding the default model formula","title":"Add formula terms to a workflow — add_formula","text":"Additionally, formula passed underlying model can also customized. case, formula argument add_model() can used. demonstrate, spline function used bill depth:","code":"library(splines) custom_formula <- workflow() %>% add_model( lm_mod, formula = body_mass_g ~ species + island + ns(bill_depth_mm, 3) ) %>% add_formula( body_mass_g ~ species + island + bill_depth_mm, blueprint = minimal ) %>% fit(data = penguins) custom_parsnip_fit <- custom_formula %>% extract_fit_parsnip() custom_fit <- custom_parsnip_fit$fit custom_fit ## ## Call: ## stats::lm(formula = body_mass_g ~ species + island + ns(bill_depth_mm, ## 3), data = data) ## ## Coefficients: ## (Intercept) speciesChinstrap speciesGentoo ## 1959.090 8.534 2352.137 ## islandDream islandTorgersen ns(bill_depth_mm, 3)1 ## 2.425 -12.002 1476.386 ## ns(bill_depth_mm, 3)2 ns(bill_depth_mm, 3)3 ## 3187.839 1686.996"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"altering-the-formula","dir":"Reference","previous_headings":"","what":"Altering the formula","title":"Add formula terms to a workflow — add_formula","text":"Finally, formula updated removed fitted workflow, corresponding model fit removed.","code":"custom_formula_no_fit <- update_formula(custom_formula, body_mass_g ~ species) try(extract_fit_parsnip(custom_formula_no_fit)) ## Error in extract_fit_parsnip(custom_formula_no_fit) : ## Can't extract a model fit from an untrained workflow. ## i Do you need to call `fit()`?"},{"path":"https://workflows.tidymodels.org/dev/reference/add_formula.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add formula terms to a workflow — add_formula","text":"","code":"workflow <- workflow() workflow <- add_formula(workflow, mpg ~ cyl) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl remove_formula(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_formula(workflow, mpg ~ disp) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ disp"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a model to a workflow — add_model","title":"Add a model to a workflow — add_model","text":"add_model() adds parsnip model workflow. remove_model() removes model specification well fitted model object. extra formulas also removed. update_model() first removes model adds new specification workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a model to a workflow — add_model","text":"","code":"add_model(x, spec, ..., formula = NULL) remove_model(x) update_model(x, spec, ..., formula = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a model to a workflow — add_model","text":"x workflow. spec parsnip model specification. ... dots future extensions must empty. formula optional formula override specify terms model. Typically, terms extracted formula recipe preprocessing methods. However, models (like survival bayesian models) use formula preprocess, specify structure model. cases, formula specifying model structure must passed unchanged model call . argument used purposes.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a model to a workflow — add_model","text":"x, updated either new removed model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a model to a workflow — add_model","text":"add_model() required step construct minimal workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Add a model to a workflow — add_model","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Add a model to a workflow — add_model","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Add a model to a workflow — add_model","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_model.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a model to a workflow — add_model","text":"","code":"library(parsnip) lm_model <- linear_reg() lm_model <- set_engine(lm_model, \"lm\") regularized_model <- set_engine(lm_model, \"glmnet\") workflow <- workflow() workflow <- add_model(workflow, lm_model) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: linear_reg() #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> workflow <- add_formula(workflow, mpg ~ .) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> remove_model(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . fitted <- fit(workflow, data = mtcars) fitted #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp hp drat #> 12.30337 -0.11144 0.01334 -0.02148 0.78711 #> wt qsec vs am gear #> -3.71530 0.82104 0.31776 2.52023 0.65541 #> carb #> -0.19942 #> remove_model(fitted) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . remove_model(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . update_model(workflow, regularized_model) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: glmnet #> update_model(fitted, regularized_model) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ . #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: glmnet #>"},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a recipe to a workflow — add_recipe","title":"Add a recipe to a workflow — add_recipe","text":"add_recipe() specifies terms model preprocessing required usage recipe. remove_recipe() removes recipe well downstream objects might get created recipe used preprocessing, prepped recipe. Additionally, model already fit, fit removed. update_recipe() first removes recipe, replaces previous recipe new one. model already fit based recipe need refit.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a recipe to a workflow — add_recipe","text":"","code":"add_recipe(x, recipe, ..., blueprint = NULL) remove_recipe(x) update_recipe(x, recipe, ..., blueprint = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a recipe to a workflow — add_recipe","text":"x workflow recipe recipe created using recipes::recipe(). recipe trained already recipes::prep(); workflows handle training internally. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_recipe_blueprint() used. Note preprocessing done separate preprocessing might done automatically underlying model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a recipe to a workflow — add_recipe","text":"x, updated either new removed recipe preprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a recipe to a workflow — add_recipe","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_recipe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a recipe to a workflow — add_recipe","text":"","code":"library(recipes) #> 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 library(magrittr) recipe <- recipe(mpg ~ cyl, mtcars) %>% step_log(cyl) workflow <- workflow() %>% add_recipe(recipe) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> • step_log() remove_recipe(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_recipe(workflow, recipe(mpg ~ cyl, mtcars)) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: None #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 0 Recipe Steps"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a tailor to a workflow — add_tailor","title":"Add a tailor to a workflow — add_tailor","text":"add_tailor() specifies post-processing steps apply usage tailor. remove_tailor() removes tailor well downstream objects might get created tailor used post-processing, fitted tailor. update_tailor() first removes tailor, replaces previous tailor new one.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a tailor to a workflow — add_tailor","text":"","code":"add_tailor(x, tailor, ...) remove_tailor(x) update_tailor(x, tailor, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a tailor to a workflow — add_tailor","text":"x workflow tailor tailor created using tailor::tailor(). tailor trained already tailor::fit(); workflows handle training internally. ... used.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a tailor to a workflow — add_tailor","text":"x, updated either new removed tailor postprocessor.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Add a tailor to a workflow — add_tailor","text":"preprocessors models trained data usual sense, postprocessors training predictions data. workflow fitted, user typically supplies training data data argument. workflows contain postprocessor requires training, users can pass available data data argument train preprocessor model. However, case postprocessor must trained well, allotting available data data argument train preprocessor model leave data train postprocessor —case, workflows need predict() preprocessor model data trained , postprocessor training predictions. Predictions data model trained likely follow different distributions predictions unseen data; thus, workflows must split supplied data two training sets, first used train preprocessor model second, called \"calibration set,\" passed trained postprocessor model generate predictions, form training data postprocessor. fitting workflow postprocessor requires training (.e. one returns TRUE .workflow_includes_calibration(workflow)), users must pass two data arguments–usual fit.workflow(data) used train preprocessor model fit.workflow(calibration) used train postprocessor. situations, randomly splitting fit.workflow(data) (rsample::initial_split(), example) sufficient prevent data leakage. However, fit.workflow(data) also arisen : case, rows data duplicated. Thus, randomly allotting train preprocessor model others train preprocessor likely result rows appearing datasets, resulting preprocessor model generating predictions rows seen . Similarly problematic situations arise context resampling situations, like time-based splits. general, use rsample::inner_split() function prevent data leakage resampling; workflows postprocessors require training passed tune package, handled internally.","code":"boots <- rsample::bootstraps(some_other_data) split <- rsample::get_rsplit(boots, 1) data <- rsample::analysis(split)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_tailor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a tailor to a workflow — add_tailor","text":"","code":"library(tailor) library(magrittr) tailor <- tailor() tailor_1 <- adjust_probability_threshold(tailor, .1) workflow <- workflow() %>% add_tailor(tailor_1) workflow #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None #> Postprocessor: tailor #> #> ── Postprocessor ───────────────────────────────────────────────────────── #> #> ── tailor ──────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. #> NA #> NA #> NA remove_tailor(workflow) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None update_tailor(workflow, adjust_probability_threshold(tailor, .2)) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: None #> Postprocessor: tailor #> #> ── Postprocessor ───────────────────────────────────────────────────────── #> #> ── tailor ──────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.2. #> NA #> NA #> NA"},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variables to a workflow — add_variables","title":"Add variables to a workflow — add_variables","text":"add_variables() specifies terms model usage tidyselect::select_helpers outcomes predictors. remove_variables() removes variables. Additionally, model already fit, fit removed. update_variables() first removes variables, replaces previous variables new ones. model already fit based original variables need refit. workflow_variables() bundles outcomes predictors single variables object, can supplied add_variables().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variables to a workflow — add_variables","text":"","code":"add_variables(x, outcomes, predictors, ..., blueprint = NULL, variables = NULL) remove_variables(x) update_variables( x, outcomes, predictors, ..., blueprint = NULL, variables = NULL ) workflow_variables(outcomes, predictors)"},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variables to a workflow — add_variables","text":"x workflow outcomes, predictors Tidyselect expressions specifying terms model. outcomes evaluated first, outcome columns removed data predictors evaluated. See tidyselect::select_helpers full range possible ways specify terms. ... used. blueprint hardhat blueprint used fine tuning preprocessing. NULL, hardhat::default_xy_blueprint() used. Note preprocessing done separate preprocessing might done underlying model. variables alternative specification outcomes predictors, useful supplying variables programmatically. NULL, argument unused, outcomes predictors used specify variables. Otherwise, must result calling workflow_variables() create standalone variables object. case, outcomes predictors completely ignored.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variables to a workflow — add_variables","text":"add_variables() returns x new variables preprocessor. remove_variables() returns x resetting model fit removing variables preprocessor. update_variables() returns x removing variables preprocessor, re-specifying new variables. workflow_variables() returns 'workflow_variables' object containing outcomes predictors.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add variables to a workflow — add_variables","text":"fit workflow, exactly one add_formula(), add_recipe(), add_variables() must specified.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/add_variables.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variables to a workflow — add_variables","text":"","code":"library(parsnip) spec_lm <- linear_reg() spec_lm <- set_engine(spec_lm, \"lm\") workflow <- workflow() workflow <- add_model(workflow, spec_lm) # Add terms with tidyselect expressions. # Outcomes are specified before predictors. workflow1 <- add_variables( workflow, outcomes = mpg, predictors = c(cyl, disp) ) workflow1 <- fit(workflow1, mtcars) workflow1 #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: c(cyl, disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 34.66099 -1.58728 -0.02058 #> # Removing the variables of a fit workflow will also remove the model remove_variables(workflow1) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: None #> Model: linear_reg() #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> # Variables can also be updated update_variables(workflow1, mpg, starts_with(\"d\")) #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: starts_with(\"d\") #> #> ── Model ───────────────────────────────────────────────────────────────── #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> # The `outcomes` are removed before the `predictors` expression # is evaluated. This allows you to easily specify the predictors # as \"everything except the outcomes\". workflow2 <- add_variables(workflow, mpg, everything()) workflow2 <- fit(workflow2, mtcars) extract_mold(workflow2)$predictors #> # A tibble: 32 × 10 #> cyl disp hp drat wt qsec vs am gear carb #> #> 1 6 160 110 3.9 2.62 16.5 0 1 4 4 #> 2 6 160 110 3.9 2.88 17.0 0 1 4 4 #> 3 4 108 93 3.85 2.32 18.6 1 1 4 1 #> 4 6 258 110 3.08 3.22 19.4 1 0 3 1 #> 5 8 360 175 3.15 3.44 17.0 0 0 3 2 #> 6 6 225 105 2.76 3.46 20.2 1 0 3 1 #> 7 8 360 245 3.21 3.57 15.8 0 0 3 4 #> 8 4 147. 62 3.69 3.19 20 1 0 4 2 #> 9 4 141. 95 3.92 3.15 22.9 1 0 4 2 #> 10 6 168. 123 3.92 3.44 18.3 1 0 4 4 #> # ℹ 22 more rows # Variables can also be added from the result of a call to # `workflow_variables()`, which creates a standalone variables object variables <- workflow_variables(mpg, c(cyl, disp)) workflow3 <- add_variables(workflow, variables = variables) fit(workflow3, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: mpg #> Predictors: c(cyl, disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 34.66099 -1.58728 -0.02058 #>"},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Augment data with predictions — augment.workflow","title":"Augment data with predictions — augment.workflow","text":"generics::augment() method workflow calls augment() underlying parsnip model new_data. x must trained workflow, resulting fitted parsnip model augment() . new_data preprocessed using preprocessor workflow, preprocessed data used generate predictions. final result contain original new_data new columns containing prediction information.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Augment data with predictions — augment.workflow","text":"","code":"# S3 method for class 'workflow' augment(x, new_data, eval_time = NULL, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Augment data with predictions — augment.workflow","text":"x workflow new_data data frame predictors eval_time censored regression models, vector time points survival probability estimated. See parsnip::augment.model_fit() details. ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Augment data with predictions — augment.workflow","text":"new_data new prediction specific columns.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/augment.workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Augment data with predictions — augment.workflow","text":"","code":"if (rlang::is_installed(\"broom\")) { library(parsnip) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") wf <- workflow() %>% add_model(model) %>% add_formula( Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime ) wf_fit <- fit(wf, attrition) augment(wf_fit, attrition) }"},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Control object for a workflow — control_workflow","title":"Control object for a workflow — control_workflow","text":"control_workflow() holds control parameters workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Control object for a workflow — control_workflow","text":"","code":"control_workflow(control_parsnip = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Control object for a workflow — control_workflow","text":"control_parsnip parsnip control object. NULL, default control argument constructed parsnip::control_parsnip().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Control object for a workflow — control_workflow","text":"control_workflow object tweaking workflow fitting process.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/control_workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Control object for a workflow — control_workflow","text":"","code":"control_workflow() #> "},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements of a workflow — extract-workflow","title":"Extract elements of a workflow — extract-workflow","text":"functions extract various elements workflow object. exist yet, error thrown. extract_preprocessor() returns formula, recipe, variable expressions used preprocessing. extract_spec_parsnip() returns parsnip model specification. extract_fit_parsnip() returns parsnip model fit object. extract_fit_engine() returns engine specific fit embedded within parsnip model fit. example, using parsnip::linear_reg() \"lm\" engine, returns underlying lm object. extract_mold() returns preprocessed \"mold\" object returned hardhat::mold(). contains information preprocessing, including either prepped recipe, formula terms object, variable selectors. extract_recipe() returns recipe. estimated argument specifies whether fitted original recipe returned. extract_parameter_dials() returns single dials parameter object. extract_parameter_set_dials() returns set dials parameter objects. extract_fit_time() returns tibble elapsed fit times. fit times correspond time parsnip engine recipe steps fit (sum summarize = TRUE) include portions elapsed time fit.workflow().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements of a workflow — extract-workflow","text":"","code":"# S3 method for class 'workflow' extract_spec_parsnip(x, ...) # S3 method for class 'workflow' extract_recipe(x, ..., estimated = TRUE) # S3 method for class 'workflow' extract_fit_parsnip(x, ...) # S3 method for class 'workflow' extract_fit_engine(x, ...) # S3 method for class 'workflow' extract_mold(x, ...) # S3 method for class 'workflow' extract_preprocessor(x, ...) # S3 method for class 'workflow' extract_postprocessor(x, estimated = TRUE, ...) # S3 method for class 'workflow' extract_parameter_set_dials(x, ...) # S3 method for class 'workflow' extract_parameter_dials(x, parameter, ...) # S3 method for class 'workflow' extract_fit_time(x, summarize = TRUE, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements of a workflow — extract-workflow","text":"x workflow ... currently used. estimated logical whether original (unfit) recipe fitted recipe returned. argument named. parameter single string parameter ID. summarize logical whether elapsed fit time returned single row multiple rows.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements of a workflow — extract-workflow","text":"extracted value object, x, described description section.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract elements of a workflow — extract-workflow","text":"Extracting underlying engine fit can helpful describing model (via print(), summary(), plot(), etc.) variable importance/explainers. However, users invoke predict() method extracted model. may preprocessing operations workflows executed data prior giving model. Bypassing can lead errors silently generating incorrect predictions. Good: Bad:","code":"workflow_fit %>% predict(new_data) workflow_fit %>% extract_fit_engine() %>% predict(new_data) # or workflow_fit %>% extract_fit_parsnip() %>% predict(new_data)"},{"path":"https://workflows.tidymodels.org/dev/reference/extract-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract elements of a workflow — extract-workflow","text":"","code":"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 recipe, formula, or a list holding the # tidyselect expressions identifying the outcomes/predictors extract_preprocessor(recipe_wf) #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Operations #> • Log transformation on: disp extract_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) #> extract_preprocessor(variable_wf) #> $outcomes #> #> expr: ^mpg #> env: 0x562a17537340 #> #> $predictors #> #> expr: ^c(cyl, disp) #> env: 0x562a17537340 #> #> attr(,\"class\") #> [1] \"workflow_variables\" # The `spec` is the parsnip spec before it has been fit. # The `fit` is the fitted parsnip model. extract_spec_parsnip(fit_formula_wf) #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> extract_fit_parsnip(fit_formula_wf) #> parsnip model object #> #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> extract_fit_engine(fit_formula_wf) #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # 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. extract_mold(fit_recipe_wf) #> $predictors #> # A tibble: 32 × 2 #> cyl disp #> #> 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 #> # ℹ 22 more rows #> #> $outcomes #> # A tibble: 32 × 1 #> mpg #> #> 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 #> # ℹ 22 more rows #> #> $blueprint #> Recipe blueprint: #> #> # Predictors: 2 #> # Outcomes: 1 #> Intercept: FALSE #> Novel Levels: FALSE #> Composition: tibble #> #> $extras #> $extras$roles #> NULL #> #> # A useful shortcut is to extract the fitted recipe from the workflow extract_recipe(fit_recipe_wf) #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Training information #> Training data contained 32 data points and no incomplete rows. #> #> ── Operations #> • Log transformation on: disp | Trained # That is identical to identical( extract_mold(fit_recipe_wf)$blueprint$recipe, extract_recipe(fit_recipe_wf) ) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit a workflow object — fit-workflow","title":"Fit a workflow object — fit-workflow","text":"Fitting workflow currently involves three main steps: Preprocessing data using formula preprocessor, calling recipes::prep() recipe. Fitting underlying parsnip model using parsnip::fit.model_spec(). Postprocessing predictions model using tailor::tailor().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit a workflow object — fit-workflow","text":"","code":"# S3 method for class 'workflow' fit(object, data, ..., calibration = NULL, control = control_workflow())"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit a workflow object — fit-workflow","text":"object workflow data data frame predictors outcomes use fitting preprocessor model. ... used calibration data frame predictors outcomes use fitting postprocessor. See \"Data Usage\" section add_tailor() information. control control_workflow() object","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit a workflow object — fit-workflow","text":"workflow object, updated fit parsnip model object$fit$fit slot.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Fit a workflow object — fit-workflow","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Fit a workflow object — fit-workflow","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Fit a workflow object — fit-workflow","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/fit-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fit a workflow object — fit-workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) model <- linear_reg() %>% set_engine(\"lm\") base_wf <- workflow() %>% add_model(model) formula_wf <- base_wf %>% add_formula(mpg ~ cyl + log(disp)) fit(formula_wf, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> recipe <- recipe(mpg ~ cyl + disp, mtcars) %>% step_log(disp) recipe_wf <- base_wf %>% add_recipe(recipe) fit(recipe_wf, mtcars) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 1 Recipe Step #> #> • step_log() #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl disp #> 67.6674 -0.1755 -8.7971 #>"},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Glance at a workflow model — glance.workflow","title":"Glance at a workflow model — glance.workflow","text":"generics::glance() method workflow calls glance() underlying parsnip model. x must trained workflow, resulting fitted parsnip model glance() .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Glance at a workflow model — glance.workflow","text":"","code":"# S3 method for class 'workflow' glance(x, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Glance at a workflow model — glance.workflow","text":"x workflow ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/glance.workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Glance at a workflow model — glance.workflow","text":"","code":"if (rlang::is_installed(\"broom\")) { library(parsnip) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") wf <- workflow() %>% add_model(model) %>% add_formula( Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime ) # Workflow must be trained to call `glance()` try(glance(wf)) wf_fit <- fit(wf, attrition) glance(wf_fit) }"},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine if a workflow has been trained — is_trained_workflow","title":"Determine if a workflow has been trained — is_trained_workflow","text":"trained workflow one gone fit(), preprocesses underlying data, fits parsnip model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine if a workflow has been trained — is_trained_workflow","text":"","code":"is_trained_workflow(x)"},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine if a workflow has been trained — is_trained_workflow","text":"x workflow.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine if a workflow has been trained — is_trained_workflow","text":"single logical indicating workflow trained .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/is_trained_workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine if a workflow has been trained — is_trained_workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) rec <- recipe(mpg ~ cyl, mtcars) mod <- linear_reg() mod <- set_engine(mod, \"lm\") wf <- workflow() %>% add_recipe(rec) %>% add_model(mod) # Before any preprocessing or model fitting has been done is_trained_workflow(wf) #> [1] FALSE wf <- fit(wf, mtcars) # After all preprocessing and model fitting is_trained_workflow(wf) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict from a workflow — predict-workflow","title":"Predict from a workflow — predict-workflow","text":"predict() method fit workflow object. nice thing predicting workflow : Preprocess new_data using preprocessing method specified workflow created fit. accomplished using hardhat::forge(), apply formula preprocessing call recipes::bake() recipe supplied. Call parsnip::predict.model_fit() using underlying fit parsnip model.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict from a workflow — predict-workflow","text":"","code":"# S3 method for class 'workflow' predict(object, new_data, type = NULL, opts = list(), ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict from a workflow — predict-workflow","text":"object workflow fit fit.workflow() new_data data frame containing new predictors preprocess predict . using recipe preprocessor, call recipes::bake() new_data passing function. type single character value NULL. Possible values \"numeric\", \"class\", \"prob\", \"conf_int\", \"pred_int\", \"quantile\", \"time\", \"hazard\", \"survival\", \"raw\". NULL, predict() choose appropriate value based model's mode. opts list optional arguments underlying predict function used type = \"raw\". list include options model object new data predicted. ... Additional parsnip-related options, depending value type. Arguments underlying model's prediction function passed (use opts argument instead). Possible arguments : interval: type equal \"survival\" \"quantile\", interval estimates added, available? Options \"none\" \"confidence\". level: type equal \"conf_int\", \"pred_int\", \"survival\", parameter tail area intervals (e.g. confidence level confidence intervals). Default value 0.95. std_error: type equal \"conf_int\" \"pred_int\", add standard error fit prediction (scale linear predictors). Default value FALSE. quantile: type equal quantile, quantiles distribution. Default (1:9)/10. eval_time: type equal \"survival\" \"hazard\", time points survival probability hazard estimated.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict from a workflow — predict-workflow","text":"data frame model predictions, many rows new_data .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/predict-workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict from a workflow — predict-workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) training <- mtcars[1:20, ] testing <- mtcars[21:32, ] model <- linear_reg() %>% set_engine(\"lm\") workflow <- workflow() %>% add_model(model) recipe <- recipe(mpg ~ cyl + disp, training) %>% step_log(disp) workflow <- add_recipe(workflow, recipe) fit_workflow <- fit(workflow, training) # This will automatically `bake()` the recipe on `testing`, # applying the log step to `disp`, and then fit the regression. predict(fit_workflow, testing) #> # A tibble: 12 × 1 #> .pred #> #> 1 25.4 #> 2 15.4 #> 3 15.8 #> 4 14.4 #> 5 13.2 #> 6 29.4 #> 7 25.4 #> 8 27.6 #> 9 14.4 #> 10 23.2 #> 11 15.9 #> 12 25.3"},{"path":"https://workflows.tidymodels.org/dev/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. generics fit, required_pkgs hardhat extract_fit_engine, extract_fit_parsnip, extract_fit_time, extract_mold, extract_parameter_dials, extract_parameter_set_dials, extract_postprocessor, extract_preprocessor, extract_recipe, extract_spec_parsnip","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy a workflow — tidy.workflow","title":"Tidy a workflow — tidy.workflow","text":"generics::tidy() method workflow calls tidy() either underlying parsnip model recipe, depending value . x must fitted workflow, resulting fitted parsnip model prepped recipe want tidy.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy a workflow — tidy.workflow","text":"","code":"# S3 method for class 'workflow' tidy(x, what = \"model\", ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy a workflow — tidy.workflow","text":"x workflow single string. Either \"model\" \"recipe\" select part workflow tidy. Defaults tidying model. ... Arguments passed methods","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/tidy.workflow.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tidy a workflow — tidy.workflow","text":"tidy unprepped recipe, use extract_preprocessor() tidy() directly.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":null,"dir":"Reference","previous_headings":"","what":"Butcher methods for a workflow — workflow-butcher","title":"Butcher methods for a workflow — workflow-butcher","text":"methods allow use butcher package reduce size workflow. calling butcher::butcher() workflow, guarantee still able predict() workflow. functions may work expected.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Butcher methods for a workflow — workflow-butcher","text":"","code":"axe_call.workflow(x, verbose = FALSE, ...) axe_ctrl.workflow(x, verbose = FALSE, ...) axe_data.workflow(x, verbose = FALSE, ...) axe_env.workflow(x, verbose = FALSE, ...) axe_fitted.workflow(x, verbose = FALSE, ...)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-butcher.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Butcher methods for a workflow — workflow-butcher","text":"x workflow. verbose information printed much memory freed butchering? ... Extra arguments possibly used underlying methods.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract elements of a workflow — workflow-extractors","title":"Extract elements of a workflow — workflow-extractors","text":"Please use extract_*() functions instead (e.g. extract_mold()). functions extract various elements workflow object. exist yet, error thrown. pull_workflow_preprocessor() returns formula, recipe, variable expressions used preprocessing. pull_workflow_spec() returns parsnip model specification. pull_workflow_fit() returns parsnip model fit. pull_workflow_mold() returns preprocessed \"mold\" object returned hardhat::mold(). contains information preprocessing, including either prepped recipe formula terms object. pull_workflow_prepped_recipe() returns prepped recipe. extracted mold object returned pull_workflow_mold().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract elements of a workflow — workflow-extractors","text":"","code":"pull_workflow_preprocessor(x) pull_workflow_spec(x) pull_workflow_fit(x) pull_workflow_mold(x) pull_workflow_prepped_recipe(x)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract elements of a workflow — workflow-extractors","text":"x workflow","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract elements of a workflow — workflow-extractors","text":"extracted value workflow, x, described description section.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow-extractors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract elements of a workflow — workflow-extractors","text":"","code":"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) #> Warning: `pull_workflow_preprocessor()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_preprocessor()` instead. #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Operations #> • Log transformation on: disp pull_workflow_preprocessor(formula_wf) #> mpg ~ cyl + log(disp) #> pull_workflow_preprocessor(variable_wf) #> $outcomes #> #> expr: ^mpg #> env: 0x562a1ccdb898 #> #> $predictors #> #> expr: ^c(cyl, disp) #> env: 0x562a1ccdb898 #> #> attr(,\"class\") #> [1] \"workflow_variables\" # The `spec` is the parsnip spec before it has been fit. # The `fit` is the fit parsnip model. pull_workflow_spec(fit_formula_wf) #> Warning: `pull_workflow_spec()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_spec_parsnip()` instead. #> Linear Regression Model Specification (regression) #> #> Computational engine: lm #> pull_workflow_fit(fit_formula_wf) #> Warning: `pull_workflow_fit()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_fit_parsnip()` instead. #> parsnip model object #> #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # 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) #> Warning: `pull_workflow_mold()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_mold()` instead. #> $predictors #> # A tibble: 32 × 2 #> cyl disp #> #> 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 #> # ℹ 22 more rows #> #> $outcomes #> # A tibble: 32 × 1 #> mpg #> #> 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 #> # ℹ 22 more rows #> #> $blueprint #> Recipe blueprint: #> #> # Predictors: 2 #> # Outcomes: 1 #> Intercept: FALSE #> Novel Levels: FALSE #> Composition: tibble #> #> $extras #> $extras$roles #> NULL #> #> # A useful shortcut is to extract the prepped recipe from the workflow pull_workflow_prepped_recipe(fit_recipe_wf) #> Warning: `pull_workflow_prepped_recipe()` was deprecated in workflows 0.2.3. #> ℹ Please use `extract_recipe()` instead. #> #> ── Recipe ──────────────────────────────────────────────────────────────── #> #> ── Inputs #> Number of variables by role #> outcome: 1 #> predictor: 2 #> #> ── Training information #> Training data contained 32 data points and no incomplete rows. #> #> ── Operations #> • Log transformation on: disp | Trained # That is identical to identical( pull_workflow_mold(fit_recipe_wf)$blueprint$recipe, pull_workflow_prepped_recipe(fit_recipe_wf) ) #> [1] TRUE"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a workflow — workflow","title":"Create a workflow — workflow","text":"workflow container object aggregates information required fit predict model. information might recipe used preprocessing, specified add_recipe(), model specification fit, specified add_model(), tailor used postprocessing, specified add_tailor(). preprocessor spec arguments allow add components workflow quickly, without go add_*() functions, add_recipe() add_model(). However, need control optional arguments functions, blueprint model formula, use add_*() functions directly instead.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a workflow — workflow","text":"","code":"workflow(preprocessor = NULL, spec = NULL, postprocessor = NULL)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a workflow — workflow","text":"preprocessor optional preprocessor add workflow. One : formula, passed add_formula(). recipe, passed add_recipe(). workflow_variables() object, passed add_variables(). spec optional parsnip model specification add workflow. Passed add_model(). postprocessor optional tailor::tailor() defining post-processing steps add workflow. Passed add_tailor().","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a workflow — workflow","text":"new workflow object.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"indicator-variable-details","dir":"Reference","previous_headings":"","what":"Indicator Variable Details","title":"Create a workflow — workflow","text":"modeling functions R create indicator/dummy variables categorical data use model formula, . specify fit model workflow(), parsnip workflows match reproduce underlying behavior user-specified model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"formula-preprocessor","dir":"Reference","previous_headings":"","what":"Formula Preprocessor","title":"Create a workflow — workflow","text":"modeldata::Sacramento data set real estate prices, type variable three levels: \"Residential\", \"Condo\", \"Multi-Family\". base workflow() contains formula added via add_formula() predict property price property type, square footage, number beds, number baths: first model create dummy/indicator variables: five independent variables fitted model OLS linear regression. model type engine, factor predictor type real estate properties converted two binary predictors, typeMulti_Family typeResidential. (third type, condos, need column baseline level). second model create dummy/indicator variables: Note four independent variables fitted model ranger random forest. model type engine, indicator variables created type real estate property sold. Tree-based models random forest models can handle factor predictors directly, don’t need conversion numeric binary variables.","code":"set.seed(123) library(parsnip) library(recipes) library(workflows) library(modeldata) data(\"Sacramento\") base_wf <- workflow() %>% add_formula(price ~ type + sqft + beds + baths) lm_spec <- linear_reg() %>% set_engine(\"lm\") base_wf %>% add_model(lm_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: linear_reg() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## ## Call: ## stats::lm(formula = ..y ~ ., data = data) ## ## Coefficients: ## (Intercept) typeMulti_Family typeResidential ## 32919.4 -21995.8 33688.6 ## sqft beds baths ## 156.2 -29788.0 8730.0 rf_spec <- rand_forest() %>% set_mode(\"regression\") %>% set_engine(\"ranger\") base_wf %>% add_model(rf_spec) %>% fit(Sacramento) ## == Workflow [trained] ================================================ ## Preprocessor: Formula ## Model: rand_forest() ## ## -- Preprocessor ------------------------------------------------------ ## price ~ type + sqft + beds + baths ## ## -- Model ------------------------------------------------------------- ## Ranger result ## ## Call: ## ranger::ranger(x = maybe_data_frame(x), y = y, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1)) ## ## Type: Regression ## Number of trees: 500 ## Sample size: 932 ## Number of independent variables: 4 ## Mtry: 2 ## Target node size: 5 ## Variable importance mode: none ## Splitrule: variance ## OOB prediction error (MSE): 7058847504 ## R squared (OOB): 0.5894647"},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"recipe-preprocessor","dir":"Reference","previous_headings":"","what":"Recipe Preprocessor","title":"Create a workflow — workflow","text":"specify model workflow() recipe preprocessor via add_recipe(), recipe controls whether dummy variables created ; recipe overrides underlying behavior model’s computational engine.","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a workflow — workflow","text":"","code":"library(parsnip) library(recipes) library(magrittr) library(modeldata) data(\"attrition\") model <- logistic_reg() %>% set_engine(\"glm\") formula <- Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime wf_formula <- workflow(formula, model) fit(wf_formula, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Attrition ~ BusinessTravel + YearsSinceLastPromotion + OverTime #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) BusinessTravelTravel_Frequently #> -2.82571 1.29473 #> BusinessTravelTravel_Rarely YearsSinceLastPromotion #> 0.64727 -0.03092 #> OverTimeYes #> 1.31904 #> #> Degrees of Freedom: 1469 Total (i.e. Null); 1465 Residual #> Null Deviance:\t 1299 #> Residual Deviance: 1194 \tAIC: 1204 recipe <- recipe(Attrition ~ ., attrition) %>% step_dummy(all_nominal(), -Attrition) %>% step_corr(all_predictors(), threshold = 0.8) wf_recipe <- workflow(recipe, model) fit(wf_recipe, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Recipe #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> 2 Recipe Steps #> #> • step_dummy() #> • step_corr() #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) Age #> -2.535e+00 -3.131e-02 #> DailyRate DistanceFromHome #> -3.126e-04 4.927e-02 #> HourlyRate MonthlyIncome #> 2.762e-03 1.127e-06 #> MonthlyRate NumCompaniesWorked #> 1.663e-06 1.956e-01 #> PercentSalaryHike StockOptionLevel #> -2.495e-02 -1.968e-01 #> TotalWorkingYears TrainingTimesLastYear #> -6.820e-02 -1.863e-01 #> YearsAtCompany YearsInCurrentRole #> 8.916e-02 -1.371e-01 #> YearsSinceLastPromotion YearsWithCurrManager #> 1.849e-01 -1.516e-01 #> BusinessTravel_Travel_Frequently BusinessTravel_Travel_Rarely #> 1.940e+00 1.080e+00 #> Education_1 Education_2 #> -1.391e-01 -2.753e-01 #> Education_3 Education_4 #> -7.324e-02 3.858e-02 #> EducationField_Life_Sciences EducationField_Marketing #> -6.939e-01 -2.212e-01 #> EducationField_Medical EducationField_Other #> -7.210e-01 -6.755e-01 #> EducationField_Technical_Degree EnvironmentSatisfaction_1 #> 2.936e-01 -9.501e-01 #> EnvironmentSatisfaction_2 EnvironmentSatisfaction_3 #> 4.383e-01 -2.491e-01 #> Gender_Male JobInvolvement_1 #> 4.243e-01 -1.474e+00 #> JobInvolvement_2 JobInvolvement_3 #> 2.297e-01 -2.855e-01 #> JobRole_Human_Resources JobRole_Laboratory_Technician #> 1.441e+00 1.549e+00 #> JobRole_Manager JobRole_Manufacturing_Director #> 1.900e-01 3.726e-01 #> JobRole_Research_Director JobRole_Research_Scientist #> -9.581e-01 6.055e-01 #> JobRole_Sales_Executive JobRole_Sales_Representative #> 1.056e+00 2.149e+00 #> JobSatisfaction_1 JobSatisfaction_2 #> -9.446e-01 -8.929e-03 #> JobSatisfaction_3 MaritalStatus_Married #> -2.860e-01 3.135e-01 #> #> ... #> and 14 more lines. variables <- workflow_variables( Attrition, c(BusinessTravel, YearsSinceLastPromotion, OverTime) ) wf_variables <- workflow(variables, model) fit(wf_variables, attrition) #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Variables #> Model: logistic_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> Outcomes: Attrition #> Predictors: c(BusinessTravel, YearsSinceLastPromotion, OverTime) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: stats::glm(formula = ..y ~ ., family = stats::binomial, data = data) #> #> Coefficients: #> (Intercept) BusinessTravelTravel_Frequently #> -2.82571 1.29473 #> BusinessTravelTravel_Rarely YearsSinceLastPromotion #> 0.64727 -0.03092 #> OverTimeYes #> 1.31904 #> #> Degrees of Freedom: 1469 Total (i.e. Null); 1465 Residual #> Null Deviance:\t 1299 #> Residual Deviance: 1194 \tAIC: 1204"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal workflow functions — .workflow_includes_calibration","title":"Internal workflow functions — .workflow_includes_calibration","text":".fit_pre(), .fit_model(), .fit_finalize() internal workflow functions partially fitting workflow object. exported usage tuning package, tune, general user never need worry .","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal workflow functions — .workflow_includes_calibration","text":"","code":".workflow_includes_calibration(workflow) .fit_pre(workflow, data) .fit_model(workflow, control) .fit_post(workflow, data) .fit_finalize(workflow)"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Internal workflow functions — .workflow_includes_calibration","text":"workflow workflow .fit_pre(), fresh workflow. .fit_model(), workflow already trained .fit_pre(). .fit_finalize(), workflow .fit_pre() .fit_model(). data data frame predictors outcomes use fitting workflow control control_workflow() object","code":""},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-internals.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Internal workflow functions — .workflow_includes_calibration","text":"","code":"library(parsnip) library(recipes) library(magrittr) model <- linear_reg() %>% set_engine(\"lm\") wf_unfit <- workflow() %>% add_model(model) %>% add_formula(mpg ~ cyl + log(disp)) wf_fit_pre <- .fit_pre(wf_unfit, mtcars) wf_fit_model <- .fit_model(wf_fit_pre, control_workflow()) wf_fit <- .fit_finalize(wf_fit_model) # Notice that fitting through the model doesn't mark the # workflow as being \"trained\" wf_fit_model #> ══ Workflow ══════════════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # Finalizing the workflow marks it as \"trained\" wf_fit #> ══ Workflow [trained] ════════════════════════════════════════════════════ #> Preprocessor: Formula #> Model: linear_reg() #> #> ── Preprocessor ────────────────────────────────────────────────────────── #> mpg ~ cyl + log(disp) #> #> ── Model ───────────────────────────────────────────────────────────────── #> #> Call: #> stats::lm(formula = ..y ~ ., data = data) #> #> Coefficients: #> (Intercept) cyl `log(disp)` #> 67.6674 -0.1755 -8.7971 #> # Which allows you to predict from it try(predict(wf_fit_model, mtcars)) #> Error in predict(wf_fit_model, mtcars) : #> Can't predict on an untrained workflow. #> ℹ Do you need to call `fit()`? predict(wf_fit, mtcars) #> # A tibble: 32 × 1 #> .pred #> #> 1 22.0 #> 2 22.0 #> 3 25.8 #> 4 17.8 #> 5 14.5 #> 6 19.0 #> 7 14.5 #> 8 23.1 #> 9 23.4 #> 10 21.6 #> # ℹ 22 more rows"},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-package.html","id":null,"dir":"Reference","previous_headings":"","what":"workflows: Modeling Workflows — workflows-package","title":"workflows: Modeling Workflows — workflows-package","text":"Managing 'parsnip' model preprocessor, model formula recipe 'recipes', can often challenging. goal 'workflows' streamline process bundling model alongside preprocessor, within object.","code":""},{"path":[]},{"path":"https://workflows.tidymodels.org/dev/reference/workflows-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"workflows: Modeling Workflows — workflows-package","text":"Maintainer: Simon Couch simon.couch@posit.co (ORCID) Authors: Davis Vaughan davis@posit.co contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-development-version","dir":"Changelog","previous_headings":"","what":"workflows (development version)","title":"workflows (development version)","text":"Package warnings errors transitioned use cli instead rlang (#241). add_variables() reference added stages vignette (@brshallo, #190). New extract_fit_time() method added return time took train workflow (#191). fit() can now take dgCMatrix sparse tibbles data values add_recipe() add_variables() used (#245, #258). predict() can now take dgCMatrix sparse tibble input new_data argument (#261).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-114","dir":"Changelog","previous_headings":"","what":"workflows 1.1.4","title":"workflows 1.1.4","text":"CRAN release: 2024-02-19 augment.workflow() previously never returned .resid column, method now return residuals conditions augment.model_fit() (#201). augment.workflow() gained eval_time argument, enabling augmenting censored regression models (#200, #213). prediction columns now appended LHS rather RHS new_data augment.workflow(), following analogous changes parsnip (#200). pull_*() functions soft-deprecated workflows v0.2.3 now warn every usage (#198). add_recipe() now error informatively supplied trained recipe (#179).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-113","dir":"Changelog","previous_headings":"","what":"workflows 1.1.3","title":"workflows 1.1.3","text":"CRAN release: 2023-02-22 workflows methods generics::tune_args() generics::tunable() now registered unconditionally (#192).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-112","dir":"Changelog","previous_headings":"","what":"workflows 1.1.2","title":"workflows 1.1.2","text":"CRAN release: 2022-11-16 Tightens integration parsnip’s machinery checking needed parsnip extension packages loaded. add_model() now error model specification supplied requires missing extension package (#184). Introduces support unsupervised model specifications via modelenv package (#180).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-110","dir":"Changelog","previous_headings":"","what":"workflows 1.1.0","title":"workflows 1.1.0","text":"CRAN release: 2022-09-26 Simon Couch now maintainer (#170). add_model() now errors try add model specification contains unknown mode. breaking change, previously cases successfully “guess” mode. change brings workflows line parsnip::fit() parsnip::fit_xy() (#160, tidymodels/parsnip#801). broom::augment() now works correctly edge case supplied hardhat blueprint composition set either \"matrix\" \"dgCMatrix\" (#148). butcher::axe_fitted() now axes recipe preprocessor stored inside workflow, reduce size template data frame stored recipe (#147). add_formula() longer silently ignores offsets supplied offset(). Instead, now errors fit() time message encourages use model formula add_model(formula = ) instead (#162).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-100","dir":"Changelog","previous_headings":"","what":"workflows 1.0.0","title":"workflows 1.0.0","text":"CRAN release: 2022-07-05 New add_case_weights(), update_case_weights(), remove_case_weights() specifying column use case weights passed underlying parsnip model (#118). R >=3.4.0 now required, line rest tidyverse.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-026","dir":"Changelog","previous_headings":"","what":"workflows 0.2.6","title":"workflows 0.2.6","text":"CRAN release: 2022-03-18 Fixed tests relied incorrect assumption version tune installed.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-025","dir":"Changelog","previous_headings":"","what":"workflows 0.2.5","title":"workflows 0.2.5","text":"CRAN release: 2022-03-16 Improved error message workflow_variables() either outcomes predictors missing (#144). Removed ellipsis dependency favor equivalent functions rlang. New extract_parameter_set_dials() extract_parameter_dials() methods extract parameter sets single parameters workflow objects.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-024","dir":"Changelog","previous_headings":"","what":"workflows 0.2.4","title":"workflows 0.2.4","text":"CRAN release: 2021-10-12 add_model() update_model() now use ... separate required arguments optional arguments, forcing optional arguments named. change made make easier us extend functions new arguments future. workflows method generics::required_pkgs() now registered unconditionally (#121). Internally cleaned remaining usage soft-deprecated pull_*() functions.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-023","dir":"Changelog","previous_headings":"","what":"workflows 0.2.3","title":"workflows 0.2.3","text":"CRAN release: 2021-07-15 workflow() gained new preprocessor spec arguments adding preprocessor (recipe formula) parsnip model specification directly workflow upon creation. many cases, can reduce lines code required construct complete workflow (#108). New extract_*() functions added supersede existing pull_*() functions. part larger move across tidymodels packages towards family generic extract_*() functions. pull_*() functions soft-deprecated, eventually removed (#106).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-022","dir":"Changelog","previous_headings":"","what":"workflows 0.2.2","title":"workflows 0.2.2","text":"CRAN release: 2021-03-10 add_variables() now allows specifying bundle model terms add_variables(variables = ), supplying pre-created set variables new workflow_variables() helper. useful supplying set variables programmatically (#92). New is_trained_workflow() determining workflow already trained call fit() (#91). fit() now errors immediately control created control_workflow() (#89). Added broom::augment() broom::glance() methods trained workflow objects (#76). Added support butchering workflow using butcher::butcher(). Updated testthat 3.0.0.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-021","dir":"Changelog","previous_headings":"","what":"workflows 0.2.1","title":"workflows 0.2.1","text":"CRAN release: 2020-10-08 New .fit_finalize() internal usage tune package.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-020","dir":"Changelog","previous_headings":"","what":"workflows 0.2.0","title":"workflows 0.2.0","text":"CRAN release: 2020-09-15 New add_variables() specifying model terms using tidyselect expressions extra preprocessing. example: One benefit specifying terms way formula method avoid preprocessing model.matrix(), might strip class predictor columns (Date columns) (#34).","code":"wf <- workflow() %>% add_variables(y, c(var1, start_with(\"x_\"))) %>% add_model(spec_lm)"},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-013","dir":"Changelog","previous_headings":"","what":"workflows 0.1.3","title":"workflows 0.1.3","text":"CRAN release: 2020-08-10 test updated reflect change parsnip 0.1.3 regarding intercept columns removed prediction (#65).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-012","dir":"Changelog","previous_headings":"","what":"workflows 0.1.2","title":"workflows 0.1.2","text":"CRAN release: 2020-07-07 using formula preprocessor add_formula(), workflows now uses model-specific information parsnip decide whether expand factors via dummy encoding (n - 1 levels), one-hot encoding (n levels), expansion . result intuitive behavior working models don’t require dummy variables. example, parsnip rand_forest() model used ranger engine, dummy variables created, ranger can handle factors directly (#51, #53).","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-011","dir":"Changelog","previous_headings":"","what":"workflows 0.1.1","title":"workflows 0.1.1","text":"CRAN release: 2020-03-17 hardhat’s minimum required version bumped 0.1.2, contains important fix recipes prepped default.","code":""},{"path":"https://workflows.tidymodels.org/dev/news/index.html","id":"workflows-010","dir":"Changelog","previous_headings":"","what":"workflows 0.1.0","title":"workflows 0.1.0","text":"CRAN release: 2019-12-30 Added NEWS.md file track changes package.","code":""}]