Skip to content

Commit eca9a31

Browse files
committed
fixed info output bug
1 parent e0f6f0e commit eca9a31

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

popper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ def calc_score(conf_matrix):
125125

126126
def print_conf_matrix(conf_matrix):
127127
tp, fn, tn, fp = conf_matrix
128-
precision = tp / (tp+fp)
129-
recall = tp / (tp+fn)
130-
print(f'Precision:{precision:0.2f}, Recall:{recall:0.2f}, TP:{tp}, FN:{fn}, TN:{tn}, FP:{fp}')
128+
precision = 'n/a'
129+
if (tp+fp) > 0:
130+
precision = f'{tp / (tp+fp):0.2f}'
131+
recall = 'n/a'
132+
if (tp+fn) > 0:
133+
recall = f'{tp / (tp+fn):0.2f}'
134+
print(f'Precision:{precision}, Recall:{recall}, TP:{tp}, FN:{fn}, TN:{tn}, FP:{fp}')
131135

132136
def popper(settings, stats, args):
133137
solver = ClingoSolver(settings)

0 commit comments

Comments
 (0)