Tune along the grid
After creating the tuning grid and a dummy specification, you need to fit a model on every grid point and evaluate the resulting model.
This is very easy in the tidymodels
framework using the tune_grid()
function, as introduced in the slides.
In the remaining exercises, you will use the credit card customers dataset, which has the following columns:
still_customer
: flag (yes or no) that indicates if a customer is still an active customertotal_trans_amt
: total sum of transactions in USDcustomer_age
: age of the customerincome_category
: labels like $60K - $80K or Less than $40K to indicate the category of yearly income- … and 16 more columns.
Feel free to inspect the customers
tibble in the console! The results of the previous exercise, tree_grid
and tune_spec
, are still loaded.
This exercise is part of the course
Machine Learning with Tree-Based Models in R
Exercise instructions
- Create three cross-validation folds of your dataset and save them as
folds
. - Create
tune_results
by tuning the specification along the grid using all predictors to predictstill_customer
, your CV folds as resamples, andmetric_set(accuracy)
. - Use
autoplot()
to plot the tuning results.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
set.seed(275)
# Create CV folds of the customers tibble
folds <- ___
# Tune along the grid
tune_results <- tune_grid(___,
___,
resamples = ___,
grid = ___,
metrics = ___)
# Plot the tuning results
___(tune_results)