-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Description
I'm trying to run a Lasso model with a specific value for lambda (penalty). I reproduce the simple example available at https://www.tidyverse.org/articles/2018/11/parsnip-0-0-1/.
library(parsnip)
penalized <- linear_reg(mixture = 1, penalty = 0.1)
penalized
glmn_fit <-
penalized %>%
set_engine("glmnet") %>%
fit(mpg ~ ., data = mtcars)
glmn_fit$spec
head(glmn_fit$fit$lambda)
tail(glmn_fit$fit$lambda)
The output:
> glmn_fit$spec
Linear Regression Model Specification (regression)
Main Arguments:
penalty = 0.1
mixture = 0
Computational engine: glmnet
Model fit template:
glmnet::glmnet(x = as.matrix(x), y = y, weights = missing_arg(),
alpha = 0, family = "gaussian")
> head(glmn_fit$fit$lambda)
[1] 5146.981 4689.737 4273.114 3893.502 3547.614 3232.454
> tail(glmn_fit$fit$lambda)
[1] 0.8195449 0.7467388 0.6804006 0.6199557 0.5648805 0.5146981
Alpha seems to be correctly set in the call of glmnet, but no lambda is set.
Session info:
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Argentina.1252
[2] LC_CTYPE=Spanish_Argentina.1252
[3] LC_MONETARY=Spanish_Argentina.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Spanish_Argentina.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] parsnip_0.0.3.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 rstudioapi_0.7 magrittr_1.5
[4] devtools_1.13.6 tidyselect_0.2.5 lattice_0.20-38
[7] R6_2.4.0 rlang_0.4.0 foreach_1.4.4
[10] dplyr_0.8.3 tools_3.6.1 grid_3.6.1
[13] packrat_0.4.9-3 glmnet_2.0-18 withr_2.1.2
[16] iterators_1.0.10 digest_0.6.18 assertthat_0.2.0
[19] tibble_2.1.3 crayon_1.3.4 Matrix_1.2-17
[22] purrr_0.2.5 tidyr_0.8.1 codetools_0.2-16
[25] vctrs_0.2.0 zeallot_0.1.0 memoise_1.1.0
[28] glue_1.3.0 compiler_3.6.1 pillar_1.4.2
[31] generics_0.0.2 backports_1.1.2 pkgconfig_2.0.1
Metadata
Metadata
Assignees
Labels
No labels