Challenge: Grid Search
Swipe to start coding
In this challenge, you will apply grid search to automatically find the best hyperparameters for a RandomForestClassifier.
You'll use a noisy two-class dataset generated with make_moons.
Your task is to:
- Define the parameter grid
param_grid:'n_estimators':[50, 100, 200]'max_depth':[3, 5, None]'min_samples_split':[2, 4]
- Create a
GridSearchCVobject using:- The model:
RandomForestClassifier(random_state=42) - The defined grid
param_grid cv=5cross-validation folds'accuracy'as the scoring metric
- The model:
- Fit the search object on the training data and print:
grid_search.best_params_- The test accuracy of the best model.
Ratkaisu
Kiitos palautteestasi!
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me an example?
Awesome!
Completion rate improved to 9.09
Challenge: Grid Search
Pyyhkäise näyttääksesi valikon
Swipe to start coding
In this challenge, you will apply grid search to automatically find the best hyperparameters for a RandomForestClassifier.
You'll use a noisy two-class dataset generated with make_moons.
Your task is to:
- Define the parameter grid
param_grid:'n_estimators':[50, 100, 200]'max_depth':[3, 5, None]'min_samples_split':[2, 4]
- Create a
GridSearchCVobject using:- The model:
RandomForestClassifier(random_state=42) - The defined grid
param_grid cv=5cross-validation folds'accuracy'as the scoring metric
- The model:
- Fit the search object on the training data and print:
grid_search.best_params_- The test accuracy of the best model.
Ratkaisu
Kiitos palautteestasi!
single