Hi Max.
Firstly, I would like to thank you for sending me the tutorial regarding 'Get started with sections of tidymodels'. That was a really good read, and it really helped. I am literally just starting out and this provided clarity.
I have read thoroughly online to solve my warning message regarding the tuning of my bagged tree model using the function tune_grid():
#Warning message
! Fold02: internal: A correlation computation is required, but `estimate` is constant and has 0 sta...
! Fold07: internal: A correlation computation is required, but `estimate` is constant and has 0 sta...
! Fold10: internal: A correlation computation is required, but `estimate` is constant and has 0 sta...
One of your explanations for this warning message in this post:
It happens when your model produces a single predicted value. R2 needs the variance (which is then zero) and produces an NA
value.
There is not much mention online for this warning message, but I also found post 1, and post 2, where you and your colleague Davis Vaughan suggest that you silently return zero back into the model.
Could I please ask:
Why is this warning message occurring when I am attempting to tune the hyperparameters on my bagged model?
Do you have any suggestions about how to fix the warning issue?
Would I need to silently replace the zero for the tuning of my model?
Here's the question and reproducible code regarding tuning my bagged model using the function tune_grid().
##Tune the bagged model
bag_res <- tune_grid(
wflow_bag %>% update_model(tune_spec_bag),
cv,
grid = bag_grid,
metrics=metric_set(rmse, rsq),
control = control_resamples(save_pred = TRUE)
)
Results from collect_predictions()
##Produce the prediction metrics for the tuned models
bag_predictions<-bag_res %>%
collect_predictions()
id .pred .row tree_depth Frequency_Blue .config
<chr> <dbl> <int> <int> <dbl> <chr>
1 Fold01 34.1 1 1 36 Model01
2 Fold01 10.1 5 1 5 Model01
3 Fold01 34.1 14 1 41 Model01
4 Fold01 35.3 1 2 36 Model02
5 Fold01 9.51 5 2 5 Model02
6 Fold01 34.3 14 2 41 Model02
7 Fold01 39.7 1 4 36 Model03
8 Fold01 9.02 5 4 5 Model03
9 Fold01 36.7 14 4 41 Model03
10 Fold01 42.3 1 5 36 Model04
# … with 260 more rows
If you are able to help me advance further and to understand this warning message better, I would like to express my deepest appreciation.
Many thanks in advance if you can help.