helena-balabin commited on
Commit
32b67df
1 Parent(s): 42ecc55

Fix threshold issue

Browse files
Files changed (1) hide show
  1. youden_index.py +1 -2
youden_index.py CHANGED
@@ -109,7 +109,7 @@ class YoudenIndex(evaluate.Metric):
109
  # 2. Determine the optimal threshold based on the Youden index
110
  fpr, tpr, thresholds = roc_curve(references, prediction_scores)
111
  idx = np.argmax(tpr - fpr)
112
- optimal_threshold = thresholds[::-1][idx + 1]
113
  # 3. Calculate PPV (precision) and NPV based on the optimal threshold
114
  optimal_predictions = np.where(prediction_scores > optimal_threshold, 1, 0)
115
  ppv = precision_score(references, optimal_predictions)
@@ -121,5 +121,4 @@ class YoudenIndex(evaluate.Metric):
121
  "roc_auc": roc_auc,
122
  "ppv": ppv,
123
  "npv": npv,
124
- "idx": idx,
125
  }
 
109
  # 2. Determine the optimal threshold based on the Youden index
110
  fpr, tpr, thresholds = roc_curve(references, prediction_scores)
111
  idx = np.argmax(tpr - fpr)
112
+ optimal_threshold = thresholds[idx-1]
113
  # 3. Calculate PPV (precision) and NPV based on the optimal threshold
114
  optimal_predictions = np.where(prediction_scores > optimal_threshold, 1, 0)
115
  ppv = precision_score(references, optimal_predictions)
 
121
  "roc_auc": roc_auc,
122
  "ppv": ppv,
123
  "npv": npv,
 
124
  }