teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

一部修正

2021/01/30 13:04

投稿

toast-uz
toast-uz

スコア3266

answer CHANGED
@@ -15,11 +15,11 @@
15
15
  ap = []
16
16
  for i in range(1000):
17
17
  y_true = np.random.randint(0, 2, SIZE)
18
- y_pred = np.random.normal(0, 1, SIZE)
18
+ y_score = np.random.normal(0, 1, SIZE)
19
- y_pred_binary = np.where(y_pred > 0.5, 1, 0)
19
+ y_pred = np.where(y_score > 0.5, 1, 0)
20
- prec.append(precision_score(y_true, y_pred_binary))
20
+ prec.append(precision_score(y_true, y_pred))
21
- recall.append(recall_score(y_true, y_pred_binary))
21
+ recall.append(recall_score(y_true, y_pred))
22
- ap.append(average_precision_score(y_true, y_pred))
22
+ ap.append(average_precision_score(y_true, y_score))
23
23
 
24
24
  _, ax = plt.subplots(1, 3)
25
25
  ax[0].scatter(prec, recall, marker='.')