Skip to content
CampusEduX

Problem 2: Perform Random Search with Multiple Hyperparameters

Easypython
Learn the Concept: Hyperparameter Tuning

Problem Description

Write a Python program that uses RandomizedSearchCV to tune both n_estimators and max_depth for a Random Forest, trying only a limited number of random combinations.

Input

A labeled dataset and search space for both hyperparameters.

Output

The best combination found and its score.

Constraints

  • Use n_iter=4 or similar to limit the search.

Example Input

text
(A labeled dataset, n_estimators: [50,100,200], max_depth: [3,5,None])

Example Output

text
Best parameters: {'n_estimators': 100, 'max_depth': 5} Best score: 0.89

Concepts Covered

RandomizedSearchCV, n_iter.

Related Problems

  • Problem 1: Perform Basic Grid Search
    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...