Commit b91dabaaa9d968466bf25f4ed9a3d41a4677b709

Authored by Tássia Camões Araújo
1 parent 336d03bf
Exists in master and in 1 other branch add_vagrant

Added MCC metric.

Showing 1 changed file with 23 additions and 0 deletions   Show diff stats
src/evaluation.py
... ... @@ -140,6 +140,29 @@ class FPR(Metric):
140 140 return (float(len(evaluation.false_positive))/
141 141 evaluation.real_negative_len)
142 142  
  143 +class MCC(Metric):
  144 + """
  145 + Matthews correlation coefficient.
  146 + """
  147 + def __init__(self):
  148 + """
  149 + Set metric description.
  150 + """
  151 + self.desc = " MCC "
  152 +
  153 + def run(self,evaluation):
  154 + """
  155 + Compute metric.
  156 + """
  157 + VP = len(evaluation.true_positive)
  158 + FP = len(evaluation.false_positive)
  159 + FN = len(evaluation.false_negative)
  160 + VN = evaluation.true_negative_len
  161 + if (VP+FP)==0 or (VP+FN)==0 or (VN+FP)==0 or (VN+FN)==0:
  162 + return 0
  163 + MCC = (((VP*VN)-(FP*FN))/math.sqrt((VP+FP)*(VP+FN)*(VN+FP)*(VN+FN)))
  164 + return MCC
  165 +
143 166 class F_score(Metric):
144 167 """
145 168 Classification accuracy metric which correlates precision and recall into an
... ...