This should error.
library(poissonreg)
#> Loading required package: parsnip
poisson_reg(penalty = 0.01) %>%
set_engine("glmnet") %>%
fit(mpg ~ ., data = mtcars) %>%
multi_predict(mtcars, type = "class")
#> # A tibble: 32 × 1
#> .pred
#> <list>
#> 1 <tibble [1 × 2]>
#> 2 <tibble [1 × 2]>
#> 3 <tibble [1 × 2]>
#> 4 <tibble [1 × 2]>
#> 5 <tibble [1 × 2]>
#> 6 <tibble [1 × 2]>
#> 7 <tibble [1 × 2]>
#> 8 <tibble [1 × 2]>
#> 9 <tibble [1 × 2]>
#> 10 <tibble [1 × 2]>
#> # ℹ 22 more rows
Created on 2026-04-19 with reprex v2.1.1
In parsnip's multi_predict() for glment models, we call parsnip:::check_pred_type() which we might want to export for this.
> linear_reg(penalty = 0.01) %>%
+ set_engine("glmnet") %>%
+ fit(mpg ~ ., data = mtcars) %>%
+ multi_predict(mtcars, type = "class")
Error in `multi_predict()`:
! For class predictions, the object should be a classification model.
Hide Traceback
▆
1. ├─... %>% multi_predict(mtcars, type = "class") at tests/testthat/test-glmnet-linear.R:322:5
2. ├─parsnip::multi_predict(., mtcars, type = "class")
3. └─parsnip:::multi_predict._elnet(., mtcars, type = "class")
4. └─parsnip:::check_pred_type(object, type)
5. └─cli::cli_abort(...)
6. └─rlang::abort(...)
This should error.
Created on 2026-04-19 with reprex v2.1.1
In parsnip's
multi_predict()for glment models, we callparsnip:::check_pred_type()which we might want to export for this.