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

speed up .config_key_from_metrics() helper #656

Merged
merged 2 commits into from
Mar 31, 2023
Merged

Conversation

simonpcouch
Copy link
Contributor

This helper gets a lot of traffic inside of collect_metrics(), and thus estimate_tune_results(). tune will see some speedup here, but stacks::add_candidates() especially benefits.

With main dev:

library(tidymodels)

set.seed(1)

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

svm_mod <-
  svm_rbf("regression", cost = tune(), rbf_sigma = tune()) %>%
  set_engine("kernlab")

svm_bayes <- tune_bayes(svm_mod, car_rec, vfold_cv(mtcars, v = 5))

bench::mark(
  old = .config_key_from_metrics(svm_bayes)
)
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 old          3.71ms   3.79ms      261.    96.1KB     10.7

With this PR:

#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new           938µs    966µs     1026.    64.8KB     10.5

R/collect.R Outdated Show resolved Hide resolved
R/collect.R Outdated Show resolved Hide resolved
simonpcouch added a commit that referenced this pull request Mar 31, 2023
@simonpcouch simonpcouch merged commit 8c4ade4 into main Mar 31, 2023
@simonpcouch simonpcouch deleted the config-speedup branch March 31, 2023 16:00
@github-actions
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 Apr 15, 2023
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.

2 participants