Databricks Machine Learning Associate Question 593
Single answerYou are performing a machine learning experiment using grid search with 3 hyperparameters: learning rate (3 values), batch size (2 values), and number of layers (4 values). You are also using 5-fold cross-validation to evaluate each configuration. How many models will be trained during this process?
- A
24
- B
30
- C
60
- D
120
Show answer and explanation
Correct answer: D
Explanation
To calculate the total number of models trained during a grid-search with k-fold cross-validation, you first compute the total number of hyperparameter combinations by multiplying the values for each hyperparameter. Then, multiply this result by the number of cross-validation folds. In this case, there are 3 * 2 * 4 = 24 hyperparameter combinations. With 5-fold cross-validation, each combination is trained 5 times, leading to a total of 24 * 5 = 120 models.
- A. Incorrect.
This option only considers the total number of hyperparameter combinations (3 * 2 * 4 = 24) but does not account for the 5-fold cross-validation.
- B. Incorrect.
This option assumes an incorrect calculation for the number of hyperparameter combinations or folds.
- C. Incorrect.
This option assumes an incorrect multiplication of the hyperparameter combinations and the number of folds.
- D. Correct.
This is the correct answer because there are 24 hyperparameter combinations (3 * 2 * 4 = 24), and each combination is trained 5 times (one for each fold in cross-validation), resulting in 24 * 5 = 120 models.