Skip to content
CampusEduX

Problem 1: Perform Basic Grid Search

Easypython
Learn the Concept: Hyperparameter Tuning

Problem Description

Write a Python program that uses GridSearchCV to tune a Decision Tree's max_depth hyperparameter over a small set of candidate values, and prints the best parameters and score.

Input

A labeled dataset and a set of candidate max_depth values.

Output

The best max_depth value and its Cross-Validation score.

Constraints

  • At least 10 labeled examples.

Example Input

text
(A labeled dataset, max_depth candidates: [2, 4, 6, None])

Example Output

text
Best parameters: {'max_depth': 4} Best score: 0.87

Concepts Covered

GridSearchCV, .best_params_, .best_score_.

Related Problems

  • Problem 2: Perform Random Search with Multiple Hyperparameters
    Easy · python
    Solve Problem
  • Problem 3: Compare Grid Search and Random Search Results
    Easy · python
    Solve Problem
  • Problem 4: Tune Regularization Strength (alpha) for Ridge Regression
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...