()
| 64 | |
| 65 | |
| 66 | def main(): |
| 67 | options = process_options() |
| 68 | reference = load_binary_list(options.reference_list) |
| 69 | sample = load_score_list(options.sample_list) |
| 70 | |
| 71 | precision, recall, threshold = metrics.precision_recall_curve(reference, sample) |
| 72 | aa = zip(precision, recall, threshold) |
| 73 | max_by_hmean = max(aa, key=lambda (p, r, t): p*r/(p+r)) |
| 74 | print("Optimal threshold: {2} for precision: {0} and recall: {1}".format(*max_by_hmean)) |
| 75 | print("AUC: {0}".format(metrics.roc_auc_score(reference, sample))) |
| 76 | |
| 77 | if options.show: |
| 78 | plt.plot(recall, precision) |
| 79 | plt.title("Precision/Recall") |
| 80 | plt.ylabel("Precision") |
| 81 | plt.xlabel("Recall") |
| 82 | plt.show() |
| 83 | |
| 84 | |
| 85 | if __name__ == "__main__": |
no test coverage detected