Exercise

Cartesian grid search in caret

In chapter 1, you learned how to use the expand.grid() function to manually define hyperparameters. The same function can also be used to define a grid of hyperparameters.

The voters_train_data dataset has already been preprocessed to make it a bit smaller so training will run faster; it has now 80 observations and balanced classes and has been loaded for you. The caret and tictoc packages have also been loaded and the trainControl object has been defined with repeated cross-validation:

fitControl <- trainControl(method = "repeatedcv",
                           number = 3,
                           repeats = 5)

Instructions 1/3

undefined XP
    1
    2
    3
  • Define a Cartesian grid of Support Vector Machine hyperparameters with the following combinations: degree should be 1, 2, or 3, scale should be 0.1, 0.01 or 0.001 and C should be held constant at 0.5.