質問編集履歴
4
不要箇所削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
このデータ分割後に次のエラーとなります。
|
16
16
|
---------------------------------------------------------------------------
|
17
17
|
ValueError Traceback (most recent call last)
|
18
|
-
|
18
|
+
|
19
19
|
3
|
20
20
|
4 from sklearn.model_selection import train_test_split
|
21
21
|
----> 5 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,stratify=binned_y)
|
3
不要箇所削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
----> 5 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,stratify=binned_y)
|
22
22
|
|
23
23
|
2 frames
|
24
|
-
|
24
|
+
|
25
25
|
1657 class_counts = np.bincount(y_indices)
|
26
26
|
1658 if np.min(class_counts) < 2:
|
27
27
|
-> 1659 raise ValueError("The least populated class in y has only 1"
|
2
エラーメッセージの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,6 +13,21 @@
|
|
13
13
|
|
14
14
|
```
|
15
15
|
このデータ分割後に次のエラーとなります。
|
16
|
+
---------------------------------------------------------------------------
|
17
|
+
ValueError Traceback (most recent call last)
|
18
|
+
<ipython-input-35-243282289f03> in <module>()
|
19
|
+
3
|
20
|
+
4 from sklearn.model_selection import train_test_split
|
21
|
+
----> 5 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,stratify=binned_y)
|
22
|
+
|
23
|
+
2 frames
|
24
|
+
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_split.py in _iter_indices(self, X, y, groups)
|
25
|
+
1657 class_counts = np.bincount(y_indices)
|
26
|
+
1658 if np.min(class_counts) < 2:
|
27
|
+
-> 1659 raise ValueError("The least populated class in y has only 1"
|
28
|
+
1660 " member, which is too few. The minimum"
|
29
|
+
1661 " number of groups for any class cannot"
|
30
|
+
|
16
31
|
ValueError: The least populated class in y has only 1 member, which is too few. The minimum number of groups for any class cannot be less than 2.
|
17
32
|
|
18
33
|
(上記のエラーの翻訳では、ValueError:yで最も人口の少ないクラスにはメンバーが1つしかなく、少なすぎます。クラスのグループの最小数は2未満にはできません。)
|
1
コードの記入方法
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
勾配部―スティング決定木のチューニングというアンサンブル学習で回帰予測を
|
2
2
|
実施しました。
|
3
|
+
```ここに言語を入力
|
3
4
|
#Numpyの配列に変換
|
4
5
|
y = np.array(dataset[target_col])#ターゲット変数
|
5
6
|
X = np.array(dataset[feature_cols])#説明変数
|
@@ -10,6 +11,7 @@
|
|
10
11
|
from sklearn.model_selection import train_test_split
|
11
12
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,stratify=binned_y)
|
12
13
|
|
14
|
+
```
|
13
15
|
このデータ分割後に次のエラーとなります。
|
14
16
|
ValueError: The least populated class in y has only 1 member, which is too few. The minimum number of groups for any class cannot be less than 2.
|
15
17
|
|