Help us understand the problem. What is going on with this article?

GridSearchCVでHoldOutを使いたい

はじめに

scikit-learn の GridSearchCV の Cross Validation方法として、N-Fold Cross Validation や Leave One Outを指定する場合、本家のドキュメントを見ればすぐにやり方は分かるが、HoldOutについてはあまり情報がなかったため、調べたときのメモ。

環境

  • python 3.X
  • scikit-learn

やり方

split数=1 の ShuffleSplit を GridSearchCV の cv に与えればよい。
HoldOutの割合は、ShffuleSplitのtest_sizeで指定する。

コード

以下はコード断片である。最後の学習部分は省略。

from lightgbm import LGBMRegressor
from sklearn.model_selection import ShuffleSplit
from sklearn.model_selection import GridSearchCV

params = {
  "num_leaves": [50, 100, 200],
  "max_depth": [50, 75],
  'min_data_in_leaf': [10, 20, 30],
  "num_leaves": [100, 200],
  "learning_rate": [0.01],
  "n_estimators": [2000, 2500, 3000],
}

estimator = LGBMRegressor()
ss = ShuffleSplit(n_splits=1, test_size=0.2, random_state=123)
GridSearchCV(estimator, params, cv=ss, scoring=r2)

参考

-Using GridsearchCV () with holdout validation

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away