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

more RNG consistency #389

Closed
topepo opened this issue Jun 29, 2021 · 1 comment · Fixed by #390
Closed

more RNG consistency #389

topepo opened this issue Jun 29, 2021 · 1 comment · Fixed by #390
Labels
bug an unexpected problem or unintended behavior feature a feature request or enhancement

Comments

@topepo
Copy link
Member

topepo commented Jun 29, 2021

First, we should make sure that package dependencies do not change the RNNG state when they are loaded. For example:

> set.seed(1)
> runif(1)
[1] 0.2655087
> 
> set.seed(1)
> library(forecast)
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
> runif(1)
[1] 0.3721239

Second, currently tune resets the RNGkind after usage:

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

RNGkind()
#> [1] "Mersenne-Twister" "Inversion"        "Rejection"
set.seed(6735)
folds <- vfold_cv(mtcars, v = 5)
spline_rec <-
  recipe(mpg ~ ., data = mtcars) %>%
  step_ns(disp, deg_free = tune("disp")) %>%
  step_ns(wt, deg_free = tune("wt"))

lin_mod <-
  linear_reg() %>%
  set_engine("lm")

spline_grid <- expand.grid(disp = 2:5, wt = 2:5)

spline_res <-
  tune_grid(lin_mod, spline_rec, resamples = folds, grid = spline_grid)

RNGkind()
#> [1] "L'Ecuyer-CMRG" "Inversion"     "Rejection"

Created on 2021-06-29 by the reprex package (v2.0.0)

We do change the RNG kind (see #331) and reset it. However, it is being reset somewhere so we need to add another on.exit().

@topepo topepo added bug an unexpected problem or unintended behavior feature a feature request or enhancement labels Jun 29, 2021
topepo added a commit that referenced this issue Jun 29, 2021
topepo added a commit that referenced this issue Jul 19, 2021
* changes for RNG consistency in #389

* refactor RNG kind fixes
@github-actions
Copy link

github-actions bot commented Aug 3, 2021

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 Aug 3, 2021
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 feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant