Skip to content

Commit

Permalink
Fix calculating FNR
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Apr 18, 2024
1 parent 61bc60b commit ae6ccf2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions metrics/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,16 @@ def TPR(self, log=True):
self.log(f"{self.tool}: TPR: ", tpr)
return tpr

def FNR(self):
def FNR(self) -> float:
"""
FNR = 1- TPR
FNR = FN / (FN + TP)
prints the false negative rate of a given tool
:return: float
"""
fnr = 1 - self.TPR(log=False)
try:
fnr = self.metrics["FN"] / (self.metrics["FN"] + self.metrics["TP"])
except ZeroDivisionError:
fnr = 0

self.log(f"{self.tool}: FNR: ", fnr)
return fnr

Expand Down

0 comments on commit ae6ccf2

Please sign in to comment.