1:对于分类数据来说,它们的target可能分配是不均匀的,比如在医疗数据当中得癌症的人比不得癌症的人少很多,这个时候,使用的数据划分方法有  StratifiedKFold  ,StratifiedShuffleSplit

2:对于分组数据来说,它的划分方法是不一样的,主要的方法有 GroupKFold,LeaveOneGroupOut,LeavePGroupOut,GroupShuffleSplit

3:对于时间关联的数据,方法有TimeSeriesSplit

eg:

采用StratifiedKFold做划分:

clf = XGBClassifier()
scores = cross_val_score(clf, iris.data, iris.target, cv=10)

采用StratifiedShuffleSplit做自定义划分:
from sklearn.model_selection import ShuffleSplit
my_cv = ShuffleSplit(n_splits=3, test_size=0.3, random_state=0)
scores = cross_val_score(clf, iris.data, iris.target, cv=my_cv)
 

参考:https://www.cnblogs.com/jiaxin359/p/8552800.html

相关文章:

  • 2021-05-31
  • 2021-10-26
  • 2021-11-30
  • 2021-11-09
  • 2021-07-16
猜你喜欢
  • 2021-09-02
  • 2021-05-07
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-07-03
  • 2022-01-17
相关资源
相似解决方案