MulaiMulai sekarang secara gratis

Changing the number of hyperparameters to tune

When we examine the model object closely, we can see that caret already did some automatic hyperparameter tuning for us: train automatically creates a grid of tuning parameters. By default, if p is the number of tuning parameters, the grid size is 3^p. But we can also specify the number of different values to try for each hyperparameter.

The data has again been preloaded as bc_train_data. The libraries caret and tictoc have also been preloaded.

Latihan ini adalah bagian dari kursus

Hyperparameter Tuning in R

Lihat Kursus

Petunjuk latihan

  • Test four different values for each hyperparameter with automatic tuning in caret.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Set seed.
set.seed(42)
# Start timer.
tic()
# Train model.
gbm_model <- train(diagnosis ~ ., 
                   data = bc_train_data, 
                   method = "gbm", 
                   trControl = trainControl(method = "repeatedcv", number = 5, repeats = 3),
                   verbose = FALSE,
                   ___)
# Stop timer.
toc()
Edit dan Jalankan Kode