시작하기무료로 시작하기

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.

이 연습은 강의의 일부입니다

Hyperparameter Tuning in R

강의 보기

연습 안내

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

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# 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()
코드 편집 및 실행