Skip to content

Instantly share code, notes, and snippets.

@xprilion
Created September 24, 2019 05:13
Show Gist options
  • Save xprilion/6e576324a24a0dd750c3b327493570f8 to your computer and use it in GitHub Desktop.
Save xprilion/6e576324a24a0dd750c3b327493570f8 to your computer and use it in GitHub Desktop.
def cm(cf):
tn = cf[0][0]
fp = cf[0][1]
fn = cf[1][0]
tp = cf[1][1]
print("TP: %d\nTN: %d" % (tp, tn))
print("FP: %d\nFN: %d" % (fp, fn))
rec = tp*100/(tp+fn)
print ("Sensitivity/Recall (TPR): %s" % (rec))
print ("Specificity (TNR/SPC): %s" % (tn*100/(fp+tn)))
# print ("FPR: %s" % (fp*100/(fp+tn)))
# print ("FNR: %s" % (fn*100/(tp+fn)))
print ("FPR: %s" % (100-(tn*100/(fp+tn))))
print ("FNR: %s" % (100-rec))
prec = tp*100/(tp+fp)
print("\nPrecision: %s" % (prec))
print("F1-score: %s" % ((2*prec*rec)/(prec+rec)))
print("\nAccuracy: %s" % ((tp+tn)*100/(tp+tn+fp+fn)))
return ((tp+tn)*100/(tp+tn+fp+fn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment