Grid Search
Validation & Tuning DS practice problem on Onlearn.
Difficulty: medium.
Topics: Understanding Hyperparameter Optimization via Grid Search, Parameter Grid Construction, K-Fold Splitting, Cartesian Product of Parameters, Model Serialization, Scoring Functions (Accuracy/F1/MSE), Supervised Learning, Statistical Modeling, Optimization Theory, Model Validation, Machine Learning Pipelines, Cross-Validation, Hyperparameter Tuning, Overfitting Mitigation, Performance Metrics, Combinatorial Search.
Implement a function grid search(model, param grid, X, y) that performs hyperparameter tuning. The function should manually iterate through all combinations of parameters, perform 3 fold cross validation for each combination, and return the best set of parameters and the corresponding best score.