Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active June 24, 2020 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mehdi-Amine/794fd5db549acdbbc25d7cec11a4eca2 to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/794fd5db549acdbbc25d7cec11a4eca2 to your computer and use it in GitHub Desktop.
accuracy of a happy neural network hopefully
def precision(tp, fp):
return tp / (tp + fp)
print(f"Precision: {precision(tp, fp)}")
def recall(tp, fn):
return tp / (tp + fn)
print(f"Recall: {recall(tp, fn)}")
def accuracy(tp, fp, tn, fn):
return (tp + tn) / (tp + fp + tn + fn)
print(f"Accuracy: {accuracy(tp, fp, tn, fn)}")
'''
Out:
Precision: 0.9876712328767123
Recall: 0.9677852348993289
Accuracy: 0.9816666666666667
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment