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

wrong penalty checking in get_glmnet_coefs() #1261

Closed
EmilHvitfeldt opened this issue Mar 7, 2025 · 2 comments · Fixed by #1262
Closed

wrong penalty checking in get_glmnet_coefs() #1261

EmilHvitfeldt opened this issue Mar 7, 2025 · 2 comments · Fixed by #1262
Labels
bug an unexpected problem or unintended behavior

Comments

@EmilHvitfeldt
Copy link
Member

When trying to rerender https://www.tidymodels.org/learn/models/coefficients/ in tidymodels/tidymodels.org#92, i found the following bug in get_glmnet_coefs(). Below is a reprex

library(tidymodels)
data(Chicago)

Chicago <- Chicago %>% select(ridership, Clark_Lake, Austin, Harlem)

glmnet_spec <- 
  linear_reg(penalty = 0.1, mixture = 0.95) %>% 
  set_engine("glmnet")

glmnet_wflow <- 
  workflow() %>% 
  add_model(glmnet_spec) %>% 
  add_formula(ridership ~ .)

glmnet_fit <- fit(glmnet_wflow, Chicago)

tidy(glmnet_fit, penalty = 5.5620)
#> 
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#> 
#>     expand, pack, unpack
#> Loaded glmnet 4.1-8
#> Error in `tidy()`:
#> ! `penalty` must be a number between 0 and 1 or `NULL`, not the number 5.56.

Created on 2025-03-07 with reprex v2.1.1

@EmilHvitfeldt EmilHvitfeldt added the bug an unexpected problem or unintended behavior label Mar 7, 2025
EmilHvitfeldt added a commit to tidymodels/tidymodels.org that referenced this issue Mar 7, 2025
@blackrow
Copy link

blackrow commented Mar 9, 2025

Yes, I am encoutring the same issue today while solving a problem. Imposing a penalty between 0 and 1 is not natural at all. Is there any workaround ?

@topepo
Copy link
Member

topepo commented Mar 10, 2025

That is a bug induced when we updated our error checkers. I'll put in a PR immediately.

topepo added a commit that referenced this issue Mar 10, 2025
topepo added a commit to tidymodels/extratests that referenced this issue Mar 10, 2025
topepo added a commit that referenced this issue Mar 10, 2025
* update snap

* changes for #1261

* use cran reticulate
topepo added a commit to tidymodels/extratests that referenced this issue Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants