-
Notifications
You must be signed in to change notification settings - Fork 95
better engine and mode checking code #530
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
Conversation
I've tried out a few combinations as additional test cases:
library(parsnip)
# check mode for given model class ----------------------------------------
# can we have this error?
proportional_hazards() %>% set_mode("regression")
#> Proportional Hazards Model Specification (regression)
#>
#> Computational engine: survival
# similar to how this errors
linear_reg() %>% set_mode("censored regression")
#> Error: Available modes for engine lm are: 'unknown', 'regression'
# check engine for given model class and mode ----------------------------
# do we want it to send a message about available engines for the mode (rather than modes for the engine)?
dt_reg_spec <- decision_tree() %>%
set_mode("regression") %>%
set_engine("C5.0")
#> Error: Available modes for engine C5.0 are: 'unknown', 'classification'
# check for missing mode arg ----------------------------------------------
# shouldn't this error and complain about missing mode (instead of engine)?
linear_reg() %>% set_mode()
#> Error in stop_incompatible_mode(spec_modes): argument "eng" is missing, with no default
# check for missing engine arg --------------------------------------------
# shouldn't this error and complain about missing engine (instead of mode)?
linear_reg() %>% set_engine()
#> Error in eval(parse(text = text, keep.source = FALSE), envir): argument "mode" is missing, with no default Created on 2021-07-19 by the reprex package (v2.0.0.9000) |
Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
Fixed these issues ☝️ except:
That's not trivial to figure out since they are separate function calls. I'm good with the current message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. I found one more thing and added a suggestion to change it
library(parsnip)
# these messages call a model type an engine
decision_tree() %>% set_mode()
#> Error: Available modes for engine decision_tree are: 'unknown', 'classification', 'regression'
proportional_hazards() %>% set_mode()
#> Error: Available modes for engine proportional_hazards are: 'unknown', 'censored regression'
proportional_hazards() %>% set_mode("regression")
#> Error: Available modes for engine proportional_hazards are: 'unknown', 'censored regression'
Created on 2021-07-20 by the reprex package (v2.0.0.9000)
Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
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. |
closes #529
Created on 2021-07-15 by the reprex package (v2.0.0)