質問編集履歴

2

from sklearn.model_selection import StratifiedKFold変更後

2018/08/13 13:35

投稿

bbettbn
bbettbn

スコア15

test CHANGED
File without changes
test CHANGED
@@ -110,8 +110,20 @@
110
110
 
111
111
  stf = StratifiedKFold(n_splits=2, random_state=0)
112
112
 
113
- for train_indices, test_indices in stf.split(labels,_):
113
+ for train_indices, test_indices in stf.split(labels,labels):
114
114
 
115
- print(test_indices)
115
+ print(len(test_indices))
116
116
 
117
117
  ```
118
+
119
+ とすると、出力は
120
+
121
+
122
+
123
+ ```
124
+
125
+ 892
126
+
127
+ 899
128
+
129
+ ```

1

model_selectionに変更

2018/08/13 13:35

投稿

bbettbn
bbettbn

スコア15

test CHANGED
File without changes
test CHANGED
@@ -97,3 +97,21 @@
97
97
 
98
98
 
99
99
  どうして、list()[0]とすることで、リスト化できたのでしょうか?この[0]の意味がよく分かりません。
100
+
101
+
102
+
103
+ model_selection変更後は、このようになると思いました。しかし、split()の引数として、X,yの二つを指定するようになっていますが、私はlabels一つだけの中身をtrainとtestに分けたいと思っています。どうしたらいいでしょうか。出力はエラーです。
104
+
105
+ ```
106
+
107
+ from sklearn.model_selection import StratifiedKFold
108
+
109
+
110
+
111
+ stf = StratifiedKFold(n_splits=2, random_state=0)
112
+
113
+ for train_indices, test_indices in stf.split(labels,_):
114
+
115
+ print(test_indices)
116
+
117
+ ```