How does grid search work?

Quick Overview

Asks how grid search tunes model hyperparameters, from choosing candidate values to cross-validating each combination and refitting the winner. Tests understanding of how the cost grows with the number of hyperparameters, how to space the grid and where the method falls short.

How does grid search work?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

How does grid search work? Take a model with a few hyperparameters to tune, such as `C` and `gamma` for an SVM. ```hint Count the fits Work out how many models get trained for a given list of candidate values and a k-fold split, then see how that number moves as you add hyperparameters. ``` ### What a Strong Answer Covers - The procedure: candidate values per hyperparameter, the Cartesian product, scoring each combination with validation or cross-validation, then picking and refitting the best - How the number of fits grows with the number of hyperparameters, values and folds - The limits of a fixed grid: resolution, value spacing and coarse-to-fine refinement - Practical properties such as determinism and parallelism ### Follow-up Questions - With a budget of 9 trials over two hyperparameters where only one matters, why does random search often beat a 3 × 3 grid? - The best value of `C` lies at the edge of your grid. What do you do? - Is the best cross-validation score an unbiased estimate of performance on new data? How would you get one? - How do you grid-search when some hyperparameters only apply to certain settings, such as `gamma` for an RBF kernel?

Overview: Asks how grid search tunes model hyperparameters, from choosing candidate values to cross-validating each combination and refitting the winner. Tests understanding of how the cost grows with the number of hyperparameters, how to space the grid and where the method falls short.

PracHub logo
General
Nov 24, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

How does grid search work?

Take a model with a few hyperparameters to tune, such as C and gamma for an SVM.

What a Strong Answer Covers Guidance

  • The procedure: candidate values per hyperparameter, the Cartesian product, scoring each combination with validation or cross-validation, then picking and refitting the best
  • How the number of fits grows with the number of hyperparameters, values and folds
  • The limits of a fixed grid: resolution, value spacing and coarse-to-fine refinement
  • Practical properties such as determinism and parallelism

Follow-up Questions Guidance

  • With a budget of 9 trials over two hyperparameters where only one matters, why does random search often beat a 3 × 3 grid?
  • The best value of C lies at the edge of your grid. What do you do?
  • Is the best cross-validation score an unbiased estimate of performance on new data? How would you get one?
  • How do you grid-search when some hyperparameters only apply to certain settings, such as gamma for an RBF kernel?