LoslegenKostenlos loslegen

Tune hyperparameters manually

If you already know which hyperparameter values you want to set, you can also manually define hyperparameters as a grid. Go to modelLookup("gbm") or search for gbm in the list of available models in caret and check under Tuning Parameters.

Note: Just as before,bc_train_data and the libraries caret and tictoc have been preloaded.

Diese Übung ist Teil des Kurses

Hyperparameter Tuning in R

Kurs anzeigen

Anleitung zur Übung

  • Define the following hyperparameter grid for a Gradient Boosting Model: the number of trees as 200; the tree complexity as 1; the learning rate as 0.1 and the minimum number of training set samples in a node to commence splitting as 10.
  • Apply the grid to the train() function of caret.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Define hyperparameter grid.
hyperparams <- expand.grid(___ = 200, 
                           ___ = 1, 
                           ___ = 0.1, 
                           ___ = 10)

# Apply hyperparameter grid to train().
set.seed(42)
gbm_model <- train(diagnosis ~ ., 
                   data = bc_train_data, 
                   method = "gbm", 
                   trControl = trainControl(method = "repeatedcv", number = 5, repeats = 3),
                   verbose = FALSE,
                   ___ = hyperparams)
Code bearbeiten und ausführen