H. Sherry Zhang
Department of Statistics and Data Sciences
University of Texas at Austin
library(usethis) create_from_github("SDS322E-26FALL/1303-ml4", fork = FALSE)
So far, for your group’s question:
In Comparing models with tidymodels (Nov 18), we compared three models for the penguins.
Today, do the same for your group’s question: compare at least three models, and choose one.
The same steps as the penguins example (compare-models.R):
Use the three models from class, in the mode that matches your response:
is_canceled, SUCCESS1, rap vs rock)
logistic_reg()nearest_neighbor(mode = "classification")rand_forest(mode = "classification")metric_set(accuracy, roc_auc): higher is bettertotal_cup_points, track_popularity)
linear_reg()nearest_neighbor(mode = "regression")rand_forest(mode = "regression")metric_set(rmse, rsq): for RMSE, lower is betterStart from the same data, and add the steps each model needs:
step_dummy(all_nominal_predictors()): categorical predictors become 0/1 dummy variablesstep_dummy() and step_normalize(all_numeric_predictors()): distances need numbers on the same scaleAnd for all models, if your data needs it:
step_naomit()step_other(all_nominal_predictors(), threshold = 0.05) (before step_dummy())Check what a recipe does with prep() and bake().
strata in initial_split() and vfold_cv(), e.g. 37% of the hotel bookings are canceled, 71% of the expeditions succeedslice_sample(n = 5000): 30 values of \(k\) \(\times\) 10 folds is a lot of KNN fitsset.seed() before the split, the folds, and tuning the random forestIn your group, compare the three models for your question. Consider:
The script ml-practice-4.R in the repository loads the four datasets and has the steps as comments. compare-models.R from Nov 18 has all the code you need.