セクション 1. 章 30
single
Challenge: Tuning Hyperparameters with RandomizedSearchCV
メニューを表示するにはスワイプしてください
RandomizedSearchCV works like GridSearchCV, but instead of checking every hyperparameter combination, it evaluates a random subset.
In the example below, the grid contains 100 combinations. GridSearchCV tests all of them, while RandomizedSearchCV can sample, for example, 20 — controlled by n_iter. This makes tuning faster, while usually finding a score close to the best.
タスク
スワイプしてコーディングを開始
You have a preprocessed penguin dataset. Tune a KNeighborsClassifier using both search methods:
- Create
param_gridwith values forn_neighbors,weights, andp. - Initialize
RandomizedSearchCV(..., n_iter=20). - Initialize
GridSearchCVwith the same grid. - Fit both searches on
X, y. - Print the grid search’s
.best_estimator_. - Print the randomized search’s
.best_score_.
解答
Note
Try running the code multiple times. RandomizedSearchCV may match the grid search score when it randomly samples the best hyperparameters.
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 30
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください