Tidymodels: Plotting Predicted vs True Values using the functions collect_predictions() and ggplot() in R

Hey Max. I hope you don't think I am overstepping but would it be possible to please help me understand the warning message for this question:

Tidymodels: Tuning hyperparameters in a bagged tree using the tune_grid() function

I am tuning all four models now: (1) glm; (2) bagged trees; (3) random forest; and (4) boosted trees.

Could I please also ask your opinion about using the function poisson_reg()? My independent predictor (frequency) represent physical counts. A commenter on Stack Overflow suggested that I use this function poissonreg::poisson_reg() in my models to prevent data leakage and thus turn the values into positive integers, which makes sense.

In your opinion, what do you think of incorporating this function into my models? Sorry for asking so many questions but I want to understand exactly what I am doing. Many thanks for your time and patience. Take care.

      ##Produce the glm model
       mod_glm<-linear_reg(mode="regression",
                   penalty = 0.1, 
                   mixture = 1) %>% 
                       poissonreg::poisson_reg() %>% 
                                   set_engine("glmnet")
   #Error
   Error: `mode` should be one of: 'unknown', 'regression'
   Run `rlang::last_error()` to see where the error occurred.
   In addition: Warning message:
   In if (!(mode %in% spec_modes)) 
   rlang::abort(glue::glue("`mode` should be one of: ",  :
  the condition has length > 1 and only the first element will be used