import math

def accuracy(tp,tn,fp,fn):
    return (tp+tn)/(tp+tn+fp+fn)

def F1_Score(tp,tn,fp,fn):
    if (2*tp)+ fp + fn == 0:
        return 0.0    
    else:
        return (2*tp)/(2*tp + fp + fn)    

def MatthewsCoeff(tp,tn,fp,fn):
    if (tp+fn==0) or (tn+fp==0) or (tp+fp==0) or (tn+fn==0):
        return 0  
    else:
        return ( (tp*tn)-(fp*fn)  ) / math.sqrt(   (tp+fp)*(tp+fn)*(tn+fp)*(tn+fn)            )