Skip to content

For glmnet models, fail if no penalty value is provided.  #481

Closed
@topepo

Description

@topepo
library(tidymodels)
data("two_class_dat")

# These should both fail in translate()

logistic_reg(penalty = c(0.01, 0.1)) %>% 
  set_engine("glmnet") %>% 
  fit(Class ~ ., data = two_class_dat)
#> parsnip model object
#> 
#> Fit time:  12ms 
#> 
#> Call:  glmnet::glmnet(x = maybe_matrix(x), y = y, family = "binomial") 
#> 
#>    Df  %Dev   Lambda
#> 1   0  0.00 0.308100
#> 2   1  4.74 0.280700
#> 3   1  8.72 0.255800
#> 4   1 12.08 0.233100
#> 5   1 14.96 0.212400
#> 6   1 17.44 0.193500
#> 7   1 19.57 0.176300
#> 8   1 21.42 0.160600
#> 9   1 23.02 0.146400
#> 10  1 24.41 0.133400
#> 11  1 25.62 0.121500
#> 12  1 26.67 0.110700
#> 13  1 27.58 0.100900
#> 14  1 28.37 0.091930
#> 15  1 29.05 0.083760
#> 16  1 29.64 0.076320
#> 17  1 30.15 0.069540
#> 18  1 30.59 0.063360
#> 19  1 30.97 0.057730
#> 20  1 31.30 0.052610
#> 21  1 31.58 0.047930
#> 22  1 31.82 0.043670
#> 23  1 32.02 0.039790
#> 24  2 32.48 0.036260
#> 25  2 33.27 0.033040
#> 26  2 33.95 0.030100
#> 27  2 34.54 0.027430
#> 28  2 35.05 0.024990
#> 29  2 35.48 0.022770
#> 30  2 35.86 0.020750
#> 31  2 36.18 0.018910
#> 32  2 36.46 0.017230
#> 33  2 36.70 0.015700
#> 34  2 36.90 0.014300
#> 35  2 37.08 0.013030
#> 36  2 37.23 0.011870
#> 37  2 37.35 0.010820
#> 38  2 37.46 0.009857
#> 39  2 37.55 0.008982
#> 40  2 37.63 0.008184
#> 41  2 37.70 0.007457
#> 42  2 37.75 0.006794
#> 43  2 37.80 0.006191
#> 44  2 37.84 0.005641
#> 45  2 37.87 0.005140
#> 46  2 37.90 0.004683
#> 47  2 37.92 0.004267
#> 48  2 37.94 0.003888
#> 49  2 37.96 0.003543
#> 50  2 37.98 0.003228
#> 51  2 37.99 0.002941
#> 52  2 38.00 0.002680
#> 53  2 38.01 0.002442
#> 54  2 38.01 0.002225
#> 55  2 38.02 0.002027
#> 56  2 38.02 0.001847
#> 57  2 38.03 0.001683
#> 58  2 38.03 0.001533
#> 59  2 38.03 0.001397
#> 60  2 38.03 0.001273
#> 61  2 38.04 0.001160
#> 62  2 38.04 0.001057
#> 63  2 38.04 0.000963
#> 64  2 38.04 0.000878
#> 65  2 38.04 0.000800

logistic_reg() %>% 
  set_engine("glmnet") %>% 
  fit(Class ~ ., data = two_class_dat)
#> parsnip model object
#> 
#> Fit time:  9ms 
#> 
#> Call:  glmnet::glmnet(x = maybe_matrix(x), y = y, family = "binomial") 
#> 
#>    Df  %Dev   Lambda
#> 1   0  0.00 0.308100
#> 2   1  4.74 0.280700
#> 3   1  8.72 0.255800
#> 4   1 12.08 0.233100
#> 5   1 14.96 0.212400
#> 6   1 17.44 0.193500
#> 7   1 19.57 0.176300
#> 8   1 21.42 0.160600
#> 9   1 23.02 0.146400
#> 10  1 24.41 0.133400
#> 11  1 25.62 0.121500
#> 12  1 26.67 0.110700
#> 13  1 27.58 0.100900
#> 14  1 28.37 0.091930
#> 15  1 29.05 0.083760
#> 16  1 29.64 0.076320
#> 17  1 30.15 0.069540
#> 18  1 30.59 0.063360
#> 19  1 30.97 0.057730
#> 20  1 31.30 0.052610
#> 21  1 31.58 0.047930
#> 22  1 31.82 0.043670
#> 23  1 32.02 0.039790
#> 24  2 32.48 0.036260
#> 25  2 33.27 0.033040
#> 26  2 33.95 0.030100
#> 27  2 34.54 0.027430
#> 28  2 35.05 0.024990
#> 29  2 35.48 0.022770
#> 30  2 35.86 0.020750
#> 31  2 36.18 0.018910
#> 32  2 36.46 0.017230
#> 33  2 36.70 0.015700
#> 34  2 36.90 0.014300
#> 35  2 37.08 0.013030
#> 36  2 37.23 0.011870
#> 37  2 37.35 0.010820
#> 38  2 37.46 0.009857
#> 39  2 37.55 0.008982
#> 40  2 37.63 0.008184
#> 41  2 37.70 0.007457
#> 42  2 37.75 0.006794
#> 43  2 37.80 0.006191
#> 44  2 37.84 0.005641
#> 45  2 37.87 0.005140
#> 46  2 37.90 0.004683
#> 47  2 37.92 0.004267
#> 48  2 37.94 0.003888
#> 49  2 37.96 0.003543
#> 50  2 37.98 0.003228
#> 51  2 37.99 0.002941
#> 52  2 38.00 0.002680
#> 53  2 38.01 0.002442
#> 54  2 38.01 0.002225
#> 55  2 38.02 0.002027
#> 56  2 38.02 0.001847
#> 57  2 38.03 0.001683
#> 58  2 38.03 0.001533
#> 59  2 38.03 0.001397
#> 60  2 38.03 0.001273
#> 61  2 38.04 0.001160
#> 62  2 38.04 0.001057
#> 63  2 38.04 0.000963
#> 64  2 38.04 0.000878
#> 65  2 38.04 0.000800

Created on 2021-05-04 by the reprex package (v1.0.0.9000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions