Commit 7ea08790 authored by Gaëtan Caillaut's avatar Gaëtan Caillaut
Browse files

fix division by zero

parent 6b04d220
......@@ -109,7 +109,11 @@ def fmeasure_deft2018(model, loader, classes, device):
precision = 0
else:
precision = tp / (tp + fp)
fm = 2 * (recall * precision) / (recall + precision)
if recall + precision == 0:
fm = 0
else:
fm = 2 * (recall * precision) / (recall + precision)
return tp, fp, fn, recall, precision, fm
......@@ -154,7 +158,11 @@ def fmeasure_deft2018_t1(model, loader, device, truth_label=1):
precision = 0
else:
precision = tp / (tp + fp)
fm = 2 * (recall * precision) / (recall + precision)
if recall + precision == 0:
fm = 0
else:
fm = 2 * (recall * precision) / (recall + precision)
return tp, fp, fn, recall, precision, fm
......@@ -200,6 +208,10 @@ def fmeasure_deft2018_t2(model, loader, classes, device):
precision = 0
else:
precision = tp / (tp + fp)
fm = 2 * (recall * precision) / (recall + precision)
if recall + precision == 0:
fm = 0
else:
fm = 2 * (recall * precision) / (recall + precision)
return tp, fp, fn, recall, precision, fm
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment