Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs and errors re: model formulas #1015

Merged
merged 7 commits into from
Nov 6, 2023
Merged

improve docs and errors re: model formulas #1015

merged 7 commits into from
Nov 6, 2023

Conversation

simonpcouch
Copy link
Contributor

Closes #770. Closes #1014.

This PR adds documentation and improves errors surrounding the "model formula." While users would have to know about the add_model(formula) argument already to find its docs, my hope here is to make a more general and findable resource.

library(tidymodels)
  
gam_wflow <- workflow() %>%
  add_formula(mpg ~ .) %>%
  add_model(gen_additive_mod("regression"))

gam_fit <- gam_wflow %>% fit(mtcars)
#> Error:
#> ! When working with generalized additive models, please supply the model
#>   specification to `workflows::add_model()` along with a `formula` argument.
#> ℹ See `?parsnip::model_formula()` to learn more.

gam_res <- gam_wflow %>% fit_resamples(bootstraps(mtcars))
#> → A | error:   ! When working with generalized additive models, please supply the model
#>                  specification to `workflows::add_model()` along with a `formula` argument.
#>                ℹ See `?parsnip::model_formula()` to learn more.
#> There were issues with some computations   A: x25
#> 
#> Warning: All models failed. Run `show_notes(.Last.tune.result)` for more
#> information.

Created on 2023-11-02 with reprex v2.0.2

I'd also recommend we link to this page in the following (dev) recipes error:

library(recipes)
recipe(mpg ~ cyl + hp / 1, mtcars)
#> Error in `inline_check()`:
#> ✖ No in-line functions should be used here.
#> ℹ The following function was found:
#> • `/`
#> ℹ Use steps to do transformations instead.

...as well as in workflows' add_model() help-file. We also ought to link ?model_formula in engine docs, but this PR is getting pretty large already; I'll leave that for another PR.

Ask: do we have a word we've already been using for "preprocessor formula"?

R/gen_additive_mod.R Show resolved Hide resolved
R/gen_additive_mod.R Show resolved Hide resolved
R/model_formula.R Show resolved Hide resolved
R/gen_additive_mod.R Show resolved Hide resolved
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be good to have 🪆

R/model_formula.R Outdated Show resolved Hide resolved
R/model_formula.R Outdated Show resolved Hide resolved
R/model_formula.R Outdated Show resolved Hide resolved
R/model_formula.R Outdated Show resolved Hide resolved
R/model_formula.R Show resolved Hide resolved
R/gen_additive_mod.R Show resolved Hide resolved
R/model_formula.R Outdated Show resolved Hide resolved
@simonpcouch simonpcouch merged commit 8a5b8b3 into main Nov 6, 2023
7 checks passed
@simonpcouch simonpcouch deleted the model-formula branch November 6, 2023 18:57
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants