You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using the excellent parsnip package, I have been running some simulations to assess the effects of changing the regularization parameter. Now, there are cases in which I get the following message:
Error in .check_glmnet_penalty_predict():
! The glmnet model was fit with a single penalty value of 10. Predicting with a value of 10 will give incorrect results from glmnet().
Run rlang::last_trace() to see where the error occurred.
This even though In all the simulations I am using the same penalty value of 10. Here post I reproducible example, all the simulations run smoothly but for some reason, the 120th simulation (that uses the same data generating process and parametrization) gives me this error.
Reproducible example
## copy your code to the clipboard and run:reprex::reprex(si=TRUE)
library(tidymodels)
asses_cv<-1n_folds<-1pen_val<-seq(from=10,to=10,length.out=1)
tuning_g<-expand_grid(penalty=pen_val,mixture=c(1))
for (iin1:120){
set.seed(i)
x1<-rnorm(100)
x2<-rnorm(100)
y<-3+rnorm(100)
train<-tibble(y,x1,x2)
lm_elne<-linear_reg(penalty= tune(),mixture= tune()) %>%
set_engine("glmnet",path_values=pen_val,thresh=1E-25)
rec<-recipe(y~.,train)
folds<-rolling_origin(train,initial= (NROW(train)-n_folds-asses_cv+1),assess=asses_cv)
wf_elne<-workflow() %>%
add_model(lm_elne) %>%
add_recipe(rec)
lm_elne_res<-tune_grid(wf_elne,resamples=folds,grid=tuning_g,metrics=yardstick::metric_set(rmse))
wf_elne %>%
finalize_workflow(select_best(lm_elne_res,metric="rmse")) %>%
fit(train) %>%
predict(train[1,])
print(i)
}
I would appreciate any comment.
Thank you very much,
The text was updated successfully, but these errors were encountered:
WARNING: use with care. Avoid supplying a single value for lambda (for predictions after CV use predict() instead). Supply instead a decreasing sequence of lambda values. glmnet relies on its warms starts for speed, and its often faster to fit a whole path than compute a single fit.
I'll discuss with the group; we could convert this to a warning but there is probably a good reason we made it an error.
Hello to all,
The problem
I have been using the excellent parsnip package, I have been running some simulations to assess the effects of changing the regularization parameter. Now, there are cases in which I get the following message:
Error in
.check_glmnet_penalty_predict()
:! The glmnet model was fit with a single penalty value of 10. Predicting with a value of 10 will give incorrect results from
glmnet()
.Run
rlang::last_trace()
to see where the error occurred.This even though In all the simulations I am using the same penalty value of 10. Here post I reproducible example, all the simulations run smoothly but for some reason, the 120th simulation (that uses the same data generating process and parametrization) gives me this error.
Reproducible example
I would appreciate any comment.
Thank you very much,
The text was updated successfully, but these errors were encountered: