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

Use condense_control() #540

Merged
merged 11 commits into from
Sep 22, 2022
Merged

Use condense_control() #540

merged 11 commits into from
Sep 22, 2022

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Sep 15, 2022

This PR reflects the changes made in tidymodels/parsnip#808.

This PR should close #449, the error isn't perfect, but it is a lot better

library(tidymodels)

rec_no_tune_1 <-
  recipe(mpg ~ ., data = mtcars) %>%
  step_normalize(all_predictors())

set.seed(363)
mt_folds <- vfold_cv(mtcars, v = 5)

glmn_mod <- decision_tree(tree_depth = tune(), min_n = 2) %>% 
  set_mode("regression") %>%
  set_engine("rpart")

workflow() %>%
  add_recipe(rec_no_tune_1) %>%
  add_model(glmn_mod) %>%
  tune_bayes(mt_folds, control = control_grid())
#> Error in `parsnip::condense_control()` at tune/R/tune_bayes.R:195:4:
#> ! Object of class `control_grid` cannot be corresed to object of class `control_bayes`.
#> • The following arguments are missing:
#> • 'no_improve', 'uncertain', 'seed', 'time_limit', and 'save_gp_scoring'

Created on 2022-09-14 by the reprex package (v2.0.1)

This means that we get more flexibility in cases where we need to pass a control object from function to function.

library(tidymodels)

rec_no_tune_1 <-
  recipe(mpg ~ ., data = mtcars) %>%
  step_normalize(all_predictors())

mt_folds <- vfold_cv(mtcars, v = 5)

tree_mod_no_tune <- decision_tree(min_n = 3) %>% 
  set_mode("regression") %>%
  set_engine("rpart")

tree_wf_no_tune <- workflow() %>%
  add_recipe(rec_no_tune_1) %>%
  add_model(tree_mod_no_tune)

# fit_resamples
tree_wf_no_tune %>%
  fit_resamples(mt_folds, control = control_bayes())
#> # Resampling results
#> # 5-fold cross-validation 
#> # A tibble: 5 × 4
#>   splits         id    .metrics         .notes          
#>   <list>         <chr> <list>           <list>          
#> 1 <split [25/7]> Fold1 <tibble [2 × 4]> <tibble [0 × 3]>
#> 2 <split [25/7]> Fold2 <tibble [2 × 4]> <tibble [0 × 3]>
#> 3 <split [26/6]> Fold3 <tibble [2 × 4]> <tibble [0 × 3]>
#> 4 <split [26/6]> Fold4 <tibble [2 × 4]> <tibble [0 × 3]>
#> 5 <split [26/6]> Fold5 <tibble [2 × 4]> <tibble [0 × 3]>

Created on 2022-09-14 by the reprex package (v2.0.1)

@EmilHvitfeldt
Copy link
Member Author

As far as I can tell, the CI errors are fixed in #541

NEWS.md Outdated Show resolved Hide resolved
Co-authored-by: Max Kuhn <[email protected]>
@EmilHvitfeldt
Copy link
Member Author

Changes has been merged :)

@github-actions
Copy link

github-actions bot commented Oct 7, 2022

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 Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uninformative error if wrong control_*() is used
2 participants