Databricks Machine Learning Associate Question 595
Single answerA data scientist is using a grid-search approach to optimize the hyperparameters of a machine learning model. The grid-search tests 3 values for the learning rate, 2 values for the batch size, and 4 values for the number of layers. Additionally, the process uses 5-fold cross-validation to evaluate each combination of hyperparameters. How many models will be trained during this process?
- A
24
- B
120
- C
60
- D
240
Show answer and explanation
Correct answer: D
Explanation
The total number of models trained during a grid-search with cross-validation is determined by multiplying the total number of hyperparameter combinations by the number of cross-validation folds. In this case, there are 3 values for the learning rate, 2 values for the batch size, and 4 values for the number of layers, resulting in 3 × 2 × 4 = 24 hyperparameter combinations. Since 5-fold cross-validation is used, each combination is evaluated 5 times, leading to a total of 24 × 5 = 240 models trained.
- A. Incorrect.
Incorrect. This number only accounts for the total number of hyperparameter combinations (3 × 2 × 4 = 24) but does not incorporate the cross-validation process.
- B. Incorrect.
Incorrect. This number is incorrect as it does not align with the calculation of the total models trained considering both hyperparameter combinations and cross-validation.
- C. Incorrect.
Incorrect. This number might look plausible, but it is a miscalculation of either the hyperparameter combinations or the cross-validation folds.
- D. Correct.
Correct. The total number of models trained is calculated as the product of the number of hyperparameter combinations and the number of cross-validation folds: (3 × 2 × 4) × 5 = 240.