@@ -0,0 +1,730 @@
+%22%22%22Utility methods for computing evaluating metrics. All methods assumes greater%0Ascores for better matches, and assumes label == 1 means match.%0A%22%22%22%0Aimport operator%0A%0A%0Adef ErrorRateAt95Recall(labels, scores):%0A    recall_point = 0.95%0A    # Sort label-score tuples by the score in descending order.%0A    sorted_scores = zip(labels, scores)%0A    sorted_scores.sort(key=operator.itemgetter(1), reverse=True)%0A%0A    # Compute error rate%0A    n_match = sum(1 for x in sorted_scores if x%5B0%5D == 1)%0A    n_thresh = recall_point * n_match%0A    tp = 0%0A    count = 0%0A    for label, score in sorted_scores:%0A        count += 1%0A        if label == 1:%0A            tp += 1%0A        if tp %3E= n_thresh:%0A            break%0A%0A    return float(count - tp) / count%0A

add evaluation metric for FPR95