Scikit-learnのGridSearchCVを使用した場合の最良のパラメータ選択と最小のモデル選択の仕組み

[概要]

機械学習モデル作成に使用される、Scikit-learnライブラリにはGridSearchCVというクラスがあります。本クラスを使用する際、グリッドサーチによる最良のパラメータ選択と、K分割交差検証による最良のモデル選択の仕組みは以下の通りです。

<サンプルコード>

# Train the model using the max depth and min samples split hyperparameters selected by grid search, along with the training data
gridsearch_tuned_model = GridSearchCV(estimator=estimator, param_grid=param_grid, cv=cv, return_train_score=False)
gridsearch_tuned_model.fit(x_train, y_train)

# Display best hyperparameter
gridsearch_tuned_model.best_params_

# Update the model to the best version
gridsearch_best_tuned_model = gridsearch_tuned_model.best_estimator_
項目仕組み
最良の
パラメータ選択
各パラメータの組合せのうち、
K回の学習を行ったモデルの平均精度が最も高かった組合せを選択
最良の
モデル選択
最良のパラメータでK回の学習を行ったK個のモデルのうち、
最も良い性能(K分の1個の検証用データによる検証結果)を示したモデルを選択

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です