Skip to content

Conversation

@hfrick
Copy link
Member

@hfrick hfrick commented Jan 22, 2023

closes #757

I'll add the corresponding test to the other glmnet tests for poisson_reg() in extratests.

library(poissonreg)
#> Loading required package: parsnip

# These should both fail in translate()

poisson_reg(penalty = c(0.01, 0.1)) %>% 
  set_engine("glmnet") %>% 
  fit(count ~ (.)^2, data = seniors)
#> Error in `.check_glmnet_penalty_fit()` at parsnip/R/poisson_reg.R:89:4:
#> ! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
#> • There are 2 values for `penalty`.
#> • To try multiple values for total regularization, use the tune package.
#> • To predict multiple penalties, use `multi_predict()`

poisson_reg() %>% 
  set_engine("glmnet") %>% 
  fit(count ~ (.)^2, data = seniors)
#> Error in `.check_glmnet_penalty_fit()` at parsnip/R/poisson_reg.R:89:4:
#> ! For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).
#> • There are 0 values for `penalty`.
#> • To try multiple values for total regularization, use the tune package.
#> • To predict multiple penalties, use `multi_predict()`

Created on 2023-01-22 with reprex v2.0.2

@hfrick hfrick merged commit 2249cbb into main Jan 22, 2023
@hfrick hfrick deleted the poisson_reg-glmnet-penalty branch January 22, 2023 15:24
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2023

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 Feb 6, 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.

For poisson_reg(engine = "glmnet") models, fail if no penalty value is provided.

2 participants