tidymodels / hardhat

Construct Modeling Packages
https://hardhat.tidymodels.org
Other
101 stars 15 forks source link

Use rlang's type checking helpers #227

Closed DavisVaughan closed 1 year ago

DavisVaughan commented 1 year ago

Closes https://github.com/tidymodels/hardhat/issues/221

Avoiding all the as_label() calls from validate_is() seems to knock off another 10% or so

With dev dplyr and dev parsnip, maybe with a few other dev versions but those are the most important for now.

library(tidymodels)

set.seed(1)

mtcars <- as_tibble(mtcars)
bs <- bootstraps(mtcars, 100)

bench::mark(
  fit_resamples(linear_reg(), mpg ~ ., bs),
  iterations = 10
)

# Before
#> # A tibble: 1 × 6
#>   expression                                  min median itr/s…¹ mem_a…² gc/se…³
#>   <bch:expr>                               <bch:> <bch:>   <dbl> <bch:b>   <dbl>
#> 1 fit_resamples(linear_reg(), mpg ~ ., bs)  4.25s  4.51s   0.218  26.8MB    3.17
#> # … with abbreviated variable names ¹​`itr/sec`, ²​mem_alloc, ³​`gc/sec`

# After
#> # A tibble: 1 × 6
#>   expression                                  min median itr/s…¹ mem_a…² gc/se…³
#>   <bch:expr>                               <bch:> <bch:>   <dbl> <bch:b>   <dbl>
#> 1 fit_resamples(linear_reg(), mpg ~ ., bs)  3.77s  4.16s   0.245  27.5MB    3.28
#> # … with abbreviated variable names ¹​`itr/sec`, ²​mem_alloc, ³​`gc/sec`
github-actions[bot] commented 1 year ago

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.