04cd555be76efc7baced753c751c4257d41eb75d,EvalMetrics.py,,ErrorRateAt95Recall,#Any#Any#,10
Before Change
def ErrorRateAt95Recall(labels, scores):
recall_point = 0.95
// Sort label-score tuples by the score in descending order.
sorted_scores = zip(labels, scores)
sorted_scores.sort(key=operator.itemgetter(1), reverse=False)
// Compute error rate
n_match = sum(1 for x in sorted_scores if x[0] == 1)
n_thresh = recall_point * n_match
tp = 0
count = 0
for label, score in sorted_scores:
count += 1
if label == 1:
tp += 1
if tp >= n_thresh:
break
return float(count - tp) / count
After Change
threshold_index = np.argmax(np.cumsum(labels) >= recall_point * np.sum(labels))
FP = np.sum(labels[:threshold_index] == 0) // Below threshold (i.e., labelled positive), but should be negative
TN = np.sum(labels[threshold_index:] == 0) // Above threshold (i.e., labelled negative), and should be negative
return float(FP) / float(FP + TN)
"""import operator
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: DagnyT/hardnet
Commit Name: 04cd555be76efc7baced753c751c4257d41eb75d
Time: 2017-07-27
Author: ducha.aiki@gmail.com
File Name: EvalMetrics.py
Class Name:
Method Name: ErrorRateAt95Recall
Project Name: Pinafore/qb
Commit Name: 9d22742baeeb608bac5594c3ece96f62f0734dce
Time: 2017-05-13
Author: sjtufs@gmail.com
File Name: qanta/buzzer/trainer.py
Class Name: Trainer
Method Name: test
Project Name: idaholab/raven
Commit Name: 3cee81f6d6f9637d21aad32d360844f6ce7a90c4
Time: 2017-06-21
Author: paul.talbot@inl.gov
File Name: framework/Optimizers/GradientBasedOptimizer.py
Class Name: GradientBasedOptimizer
Method Name: _removeRedundantTraj