小编Par*_*kla的帖子

y 中人口最少的类只有 1 个成员,太少了。任何班级的最少小组人数不能少于2人。该怎么办

在此输入图像描述

我正在 covid 19 数据集上制作 ML 项目并收到这样的错误

from sklearn.model_selection import StratifiedShuffleSplit
split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42)
for train_index, test_index in split.split(covid, covid['Death Ratio']):
    strat_train_set = covid.loc[train_index]
    strat_test_set = covid.loc[test_index]
Run Code Online (Sandbox Code Playgroud)

我尝试了很多方法来解决,但我没能做到

ValueError                                Traceback (most recent call last)
<ipython-input-31-42056912ab46> in <module>
      1 from sklearn.model_selection import StratifiedShuffleSplit
      2 split = StratifiedShuffleSplit(n_splits=1, test_size=0.2, random_state=42)
----> 3 for train_index, test_index in split.split(covid, covid['Death Ratio']):
      4     strat_train_set = covid.loc[train_index]
      5     strat_test_set = covid.loc[test_index]

c:\users\hp\appdata\local\programs\python\python37\lib\site-packages\sklearn\model_selection\_split.py in split(self, X, y, groups)
   1385         """
   1386         X, y, groups = indexable(X, …
Run Code Online (Sandbox Code Playgroud)

python machine-learning scikit-learn

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

machine-learning ×1

python ×1

scikit-learn ×1