Skip to content

Commit

Permalink
#352 related: considering eps for micro prec/recall.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Jul 27, 2022
1 parent 1a5e673 commit 8d78e56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arekit/contrib/utils/evaluation/results/metrics_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def calc_precision_micro(get_result_by_label_func, labels):
results = [get_result_by_label_func(label) for label in labels]
tp_sum = sum([len(res.filter_comparison_true()) for res in results])
tp_fn_sum = sum([len(res) for res in results])
return (1.0 * tp_sum) / tp_fn_sum
return (1.0 * tp_sum) / (tp_fn_sum if tp_fn_sum != 0 else 1e-5)


def calc_recall_micro(get_origin_answers_by_label_func,
Expand All @@ -52,7 +52,7 @@ def calc_recall_micro(get_origin_answers_by_label_func,
results = [get_result_answers_by_label_func(label) for label in labels]
tp_sum = sum([len(res.filter_comparison_true()) for res in results])
tp_fp_sum = sum([len(get_origin_answers_by_label_func(label)) for label in labels])
return (1.0 * tp_sum) / tp_fp_sum
return (1.0 * tp_sum) / (tp_fp_sum if tp_fp_sum != 0 else 1e-5)


def calc_prec_and_recall(cmp_table,
Expand Down

0 comments on commit 8d78e56

Please sign in to comment.