Session Ready
Exercise

Random search

As discussed before, grid search can become slow and compute-intensive fairly quickly as the number of hyperparameters and their sets of candidate values increases. To tackle this issue, you will conduct a random search instead.

In a random search you let caret sample from the range/set of values a hyperparameter can take. This means that so far, you cannot specify your own custom hyperparameter values as was done in the previous exercise. Despite this limitation, random search performs quite well in general and is very easy to implement: simply specify search="random" in your training specs and tuneLength=X in your train() call, where X is the number of candidate hyperparameter vectors to consider.

Again, caret is loaded and the car_train dataset is also available.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Set the random seed to 42. Then create a train control object named trc corresponding to a single 10-fold cross validation and conduct a random hyperparameter search by specifying search="random".