質問編集履歴

2

エラーコードの更新

2020/01/30 07:47

投稿

svsvi
svsvi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -220,13 +220,13 @@
220
220
 
221
221
  ```
222
222
 
223
- ### 新しいエラーコード
223
+ ### エラーコード
224
-
224
+
225
- ```
225
+ ```
226
-
226
+
227
- TypeError Traceback (most recent call last)
227
+ ValueError Traceback (most recent call last)
228
-
228
+
229
- <ipython-input-10-8349a4884248> in <module>
229
+ <ipython-input-13-b74e493b703b> in <module>
230
230
 
231
231
  70
232
232
 
@@ -270,46 +270,18 @@
270
270
 
271
271
  ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays)
272
272
 
273
- 206 """
274
-
275
- 207
276
-
277
- --> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
278
-
279
- 209 uniques = np.unique(lengths)
280
-
281
273
  210 if len(uniques) > 1:
282
274
 
283
-
284
-
285
- ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in <listcomp>(.0)
286
-
287
- 206 """
288
-
289
- 207
290
-
291
- --> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
292
-
293
- 209 uniques = np.unique(lengths)
294
-
295
- 210 if len(uniques) > 1:
296
-
297
-
298
-
299
- ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _num_samples(x)
300
-
301
- 150 if len(x.shape) == 0:
302
-
303
- 151 raise TypeError("Singleton array %r cannot be considered"
275
+ 211 raise ValueError("Found input variables with inconsistent numbers of"
304
-
276
+
305
- --> 152 " a valid collection." % x)
277
+ --> 212 " samples: %r" % [int(l) for l in lengths])
306
-
278
+
307
- 153 # Check that shape is returning an integer or default to len
279
+ 213
308
-
280
+
309
- 154 # Dask dataframes may not return numeric shape[0] value
281
+ 214
310
-
311
-
312
-
282
+
283
+
284
+
313
- TypeError: Singleton array 1.0 cannot be considered a valid collection.
285
+ ValueError: Found input variables with inconsistent numbers of samples: [1, 12000]
314
-
286
+
315
- ```
287
+ ```

1

いただいた回答に修正した際のエラーコードを表示しました

2020/01/30 07:47

投稿

svsvi
svsvi

スコア7

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  具体的なプログラムを教えてもらえると助かります。
6
6
 
7
- ### ソースコード
7
+ ### 最初のソースコード
8
8
 
9
9
  ```
10
10
 
@@ -207,3 +207,109 @@
207
207
  ValueError: Classification metrics can't handle a mix of binary and multiclass-multioutput targets
208
208
 
209
209
  ```
210
+
211
+ ###修正後のy_pred2
212
+
213
+ 回答でいただいたものをもとにy_pred2を変えたらエラーが変わりました
214
+
215
+ ```
216
+
217
+ pred = model.predict(x_test, batch_size=1, verbose=0)
218
+
219
+ y_pred2 = np.max(pred)
220
+
221
+ ```
222
+
223
+ ### 新しいエラーコード
224
+
225
+ ```
226
+
227
+ TypeError Traceback (most recent call last)
228
+
229
+ <ipython-input-10-8349a4884248> in <module>
230
+
231
+ 70
232
+
233
+ 71
234
+
235
+ ---> 72 print('confusion matrix 混合行列 =\n ', confusion_matrix(y_true=y_test2, y_pred=y_pred2))#混合行列
236
+
237
+ 73 print('accuracy 正解率 = ', accuracy_score(y_true=y_test2, y_pred=y_pred2))#正解率(正しく分類されたデータ数の割合)
238
+
239
+ 74 print('precision 適合率 = ', precision_score(y_true=y_test2, y_pred=y_pred2))#適合率(Aに分類されたデータで実際にAであるデータ数の割合)
240
+
241
+
242
+
243
+ ~\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py in confusion_matrix(y_true, y_pred, labels, sample_weight, normalize)
244
+
245
+ 266
246
+
247
+ 267 """
248
+
249
+ --> 268 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
250
+
251
+ 269 if y_type not in ("binary", "multiclass"):
252
+
253
+ 270 raise ValueError("%s is not supported" % y_type)
254
+
255
+
256
+
257
+ ~\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py in _check_targets(y_true, y_pred)
258
+
259
+ 78 y_pred : array or indicator matrix
260
+
261
+ 79 """
262
+
263
+ ---> 80 check_consistent_length(y_true, y_pred)
264
+
265
+ 81 type_true = type_of_target(y_true)
266
+
267
+ 82 type_pred = type_of_target(y_pred)
268
+
269
+
270
+
271
+ ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_consistent_length(*arrays)
272
+
273
+ 206 """
274
+
275
+ 207
276
+
277
+ --> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
278
+
279
+ 209 uniques = np.unique(lengths)
280
+
281
+ 210 if len(uniques) > 1:
282
+
283
+
284
+
285
+ ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in <listcomp>(.0)
286
+
287
+ 206 """
288
+
289
+ 207
290
+
291
+ --> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
292
+
293
+ 209 uniques = np.unique(lengths)
294
+
295
+ 210 if len(uniques) > 1:
296
+
297
+
298
+
299
+ ~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in _num_samples(x)
300
+
301
+ 150 if len(x.shape) == 0:
302
+
303
+ 151 raise TypeError("Singleton array %r cannot be considered"
304
+
305
+ --> 152 " a valid collection." % x)
306
+
307
+ 153 # Check that shape is returning an integer or default to len
308
+
309
+ 154 # Dask dataframes may not return numeric shape[0] value
310
+
311
+
312
+
313
+ TypeError: Singleton array 1.0 cannot be considered a valid collection.
314
+
315
+ ```