Last active
April 9, 2019 16:30
-
-
Save arthurdouillard/c26c51da91e1010fab3528211cee6a4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute_metrics(true_pos, false_pos, false_neg): | |
"""Compute the precision, recall, and f1 score.""" | |
precision = true_pos / (true_pos + false_pos) | |
recall = true_pos / (true_pos + false_neg) | |
if precision == 0 or recall == 0: | |
return precision, recall, 0 | |
f1 = 2 / (1 / precision + 1 / recall) | |
return precision, recall, f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment