How is grid search used for hyperparameter tuning?

Grid search is a method that tries every possible combination of predefined hyperparameter values to find the best configuration for a model. The process works as follows:
1. The researcher defines a set of candidate values for each hyperparameter (such as the learning rate, the number of trees or the maximum depth).
2. Grid search generates a grid of all possible combinations of these values.
3. The model is trained on each combination, using techniques such as cross-validation to measure performance.
4. The combination that gives the best result on a chosen metric (such as accuracy or RMSE) is selected.