juliasilge / juliasilge.com

My blog, built with blogdown and Hugo :link:
https://juliasilge.com/
40 stars 27 forks source link

Hyperparameter tuning and #TidyTuesday food consumption | Julia Silge #36

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

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/

caimiao0714 commented 2 years ago

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

juliasilge commented 2 years ago

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
)
caimiao0714 commented 2 years ago

Great! That works for me. Thank you!

MCV97 commented 1 year ago

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

Thank you to anyone who might respond.

juliasilge commented 1 year ago

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

MCV97 commented 1 year ago

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?

juliasilge commented 1 year ago

@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.

datasartoria commented 8 months ago

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)

juliasilge commented 8 months ago

@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).