Get startedGet started for free

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)

This exercise is part of the course

Hyperparameter Tuning in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Define Cartesian grid
man_grid <- ___(degree = ___, 
                scale = ___, 
                C = ___)
Edit and Run Code