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

make model package dependencies mode-specific #604

Closed
topepo opened this issue Nov 17, 2021 · 1 comment · Fixed by #629
Closed

make model package dependencies mode-specific #604

topepo opened this issue Nov 17, 2021 · 1 comment · Fixed by #629
Labels
bug an unexpected problem or unintended behavior

Comments

@topepo
Copy link
Member

topepo commented Nov 17, 2021

parsnip registers required packages for a model/engine combination. The package list serves as a requirement for model fitting, prediction, and now deployment.

The problem: since the package dependency is not mode dependent, we will have extra packages that are installed and loaded for modes that do not need them. For example, if the censored package is loaded, the censored and pec packages are required for classification and regression models.

library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
library(censored)

decision_tree() %>% 
  set_mode("regression") %>% 
  req_pkgs()
#> [1] "censored" "pec"      "rpart"

Created on 2021-11-15 by the reprex package (v2.0.0)

This is also a problem when we are listing engine in the parsnip docs since there is no way to note that censored is required to use a particular mode.

Note that this has not been an issue to date since engines that work for multiple modes have had the same package dependencies. censored is changing that with the new "censored regression" mode.

An option can be added to set_dependency() for the mode the structure of the parsnip database for required packages would have a mode column. get_model_spec() should also be updated to make sure the correct packages are saved in the method slot when the model is fit. This would affect new models created with parsnip.

What about existing fitted models? These should be fine since there is not really an issue yet (pre-censored). Model specifications should also be fine since the methods slot is not yet populated.

req_pkg() (more specifically get_pkgs()) will also change to take into account the mode.

@topepo topepo added the bug an unexpected problem or unintended behavior label Nov 17, 2021
@github-actions
Copy link

This issue 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 Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant