1. What is GridSearch CV
Grid search is exploratory way to find hyper parameters making best score of model.
그리드 서치를 하는 이유는 " 가장 우수한 성능을 보이는 모델의 하이퍼 파라미터를 찾기 위해서 ". 이유는 단순하다. 모든 경우의 수를 때려 넣어보고 가장 성능이 좋게 만드는 모델의 하이퍼 파라미터를 찾는거다.
[Machine learning] 쉽게 설명하는 Grid search - 모델 성능을 최고로 만드는 hyper parameter를 찾아서 (200727)
index 1. Grid search 의 정의 2. 코드 구현 및 결과 3. 유사한 다른 방법들 1. Grid search 란 무엇인가? 0) 컨셉 : 모델에게 가장 적합한 하이퍼 파라미터를 찾기 Grid search (격자 탐색) 은 모델 하이퍼 파라..
huidea.tistory.com
2. Document
- sklearn.model_selection.GridSearchCV(estimator, param_grid, , scoring=None, n_jobs=None, refit=True, cv=None, verbose=0, pre_dispatch='2n_jobs', error_score=nan, return_train_score=False)
- Parameters
- estimator : This is assumed to implement the scikit-learn estimator interface
- param_grid : Dictionary with parameters names as keys and lists of parameters setting to try as value (Pipeline을 통해 전처리한 데이터셋은 model__.max_depth으로 모델 객체로 key값을 지정해준다)
- n_jobs : Number of jobs to run in parallel
- cv : Determines the cross-validation splitting strategy
- Attributes
- cv_results : A dict keys as column headers and values as columns, that can be imported into a pandas DataFrame.
- best_estimator__ : Estimator that was chosen by the search
- best_score__ : Mean cross-validation score of the best_estimator
- best_params__ : Parameter setting that gave the best results on the hold out data
3. Example
forest_params = {"max_depth": range(6, 12), "max_features": range(4, 19)}
forest_grid = GridSearchCV(forest, forest_params, cv=5, n_jobs=-1, verbose=True)
forest_grid.fit(X_train, y_train)
forest_grid.best_params_, forest_grid.best_score_
# ({'max_depth': 9, 'max_features': 6}, 0.951)
best_accuracy_model = forest_grid.best_estimator_
'Course > [Kaggle] Data Science' 카테고리의 다른 글
[FE] Creating Features (0) | 2022.02.21 |
---|---|
[FE] Mutual Information (0) | 2022.02.21 |
[ML] Data Leakage (0) | 2022.02.19 |
[ML] XGBoost (0) | 2022.02.19 |
[ML] Cross-Validation (0) | 2022.02.19 |