juliasilge.com icon indicating copy to clipboard operation
juliasilge.com copied to clipboard

Hyperparameter tuning and #TidyTuesday food consumption | Julia Silge

Open utterances-bot opened this issue 3 years ago • 9 comments

Hyperparameter tuning and #TidyTuesday food consumption | Julia Silge

Last week I published a screencast demonstrating how to use the tidymodels framework and specifically the recipes package. Today, I’m using this week’s #TidyTuesday dataset on food consumption around the world to show hyperparameter tuning!

https://juliasilge.com/blog/food-hyperparameter-tune/

utterances-bot avatar Jul 05 '21 13:07 utterances-bot

Hi Julia,

Thank you for this great tutorial! I found it to be super useful. But I have a small issue with reproducing the tune_grid code.

> rf_grid <- tune_grid(
+   asia ~ .,
+   model = rf_spec,
+   resamples = food_boot
+ )
Error: The first argument to [tune_grid()] should be either a model or workflow.

I also tried to swap the position of asia ~ ., and model = rf_spec, but it does not work.

Thanks, Miao

caimiao0714 avatar Jul 05 '21 13:07 caimiao0714

The blog post you are looking at is fairly old, and there was a change to tune a while back so that you should now put either a workflow or a model first. Hence the error message:

The first argument to [fit_resamples()] should be either a model or workflow.

The fix is to put your model or workflow as the first argument, like this (without a name, no model):

tune_grid(
  rf_spec,
  asia ~ ., 
  food_boot
)

juliasilge avatar Jul 05 '21 16:07 juliasilge

Great! That works for me. Thank you!

caimiao0714 avatar Jul 05 '21 16:07 caimiao0714

Hello Is there a way to train/fit using an AdaBoost model using tidymodels?

Thank you to anyone who might respond.

MCV97 avatar Nov 30 '22 12:11 MCV97

@MCV97 You can see the boosted tree models available here, if you want to take a look at what's available.

juliasilge avatar Nov 30 '22 15:11 juliasilge

Thank you! Is there any way to change the loss function when using the engine spark? Or is there any engine (other than xgboost) that allows me to change the loss function?

MCV97 avatar Nov 30 '22 15:11 MCV97

@MCV97 I'm not sure about that, actually. I recommend asking this on RStudio Community, which is a great forum for getting help with these kinds of modeling questions.

juliasilge avatar Nov 30 '22 15:11 juliasilge

Hi Julia ! I have a fitted model produced from a racing workflow that I would like to use to make predictions on new observations. When using predict I return an error. This is what my extract and fitted code looks like. boosting_test_results <- race_results %>% extract_workflow("boosting") %>% finalize_workflow(best_results) %>% last_fit(split = screen_split_win)

datasartoria avatar Oct 18 '23 20:10 datasartoria

@datasartoria If you have the output of last_fit(), you'll need to use extract_workflow() to get a fitted workflow you can predict with, so something like extract_workflow(boosting_test_results).

juliasilge avatar Oct 18 '23 20:10 juliasilge