Hyperparameter Tuning interview question

Machine LearningHyperparameter TuningCross-Validationbasic

How does grid search look for good hyperparameters?

  1. AIt evaluates every combination of the candidate values listed for each hyperparameter and keeps the best-scoring one.
  2. BIt draws a fixed number of configurations at random from a range for each hyperparameter and keeps the best-scoring one.
  3. CIt fits a probabilistic model of the validation score and uses it to choose the most promising configuration to try next.
  4. DIt computes the gradient of the validation loss with respect to each hyperparameter and takes steps in the downhill direction.
Show the answer and explanation

Correct answer: A, It evaluates every combination of the candidate values listed for each hyperparameter and keeps the best-scoring one.

Explanation Hyperparameter Tuning

Grid search is exhaustive: you list candidate values for each hyperparameter, it forms the Cartesian product of those lists, evaluates every combination (usually with cross-validation) and keeps the best one. In scikit-learn this is GridSearchCV.

Why the other descriptions are wrong:

  • Sampling a fixed number of random configurations is random search.
  • Fitting a probabilistic model of the score to choose the next trial is Bayesian optimization.
  • Following the gradient of the validation loss is gradient-based tuning; grid search uses no gradients and works for discrete settings too.

The cost grows multiplicatively: 4 hyperparameters with 5 values each already give 5⁴ = 625 combinations, before multiplying by the number of CV folds.

Interview tip: say grid search is simple and reproducible but scales badly with the number of hyperparameters, which is why random search or Bayesian optimization is preferred for large spaces.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Machine Learning questions

  1. What is the difference between batch gradient descent and stochastic gradient descent (SGD)?
  2. In reinforcement learning vocabulary, what is the reward?
  3. Both series below rise at a similar average rate. Series A was generated as a linear trend plus stationary noise; Series B is a random walk with drift. Which…
  4. A churn model produced this confusion matrix on 10,000 customers, and a manager celebrates its 98.8% accuracy. What is the model's balanced accuracy, and what…
  5. For the query "waterproof hiking boots", assessors graded four products as relevant: Boot-X (3), Boot-Y (3), Boot-Z (2) and Sock-K (1); every other product is…