0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

記事投稿キャンペーン 「AI、機械学習」

sklearn.SequentialFeatureSelector内でGroupKFoldを行う

Posted at

SequentialFeatureSelector内でGroupKFoldを行う

パラメータの"cv"には、list()化したスプリットを入れましょう。
"An iterable yielding (train, test) splits as arrays of indices."

例:
from sklearn.model_selection import GroupKFold
gkf = GroupKFold(n_splits=3)
gkf_split = list(gkf.split(X, y, groups=groups))
selector = SequentialFeatureSelector(model, n_features_to_select=nb_feat, direction=direction, scoring="r2", cv=gkf_split)
selector.fit(X, y)

参考

sklearn.feature_selection.SequentialFeatureSelectorの公式は↓
https://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.SequentialFeatureSelector.html#sklearn.feature_selection.SequentialFeatureSelector.set_params

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?