From ae4716333e5e4cbe466296cd636fec05354ac960 Mon Sep 17 00:00:00 2001 From: WonJin Yoon Date: Tue, 5 Mar 2024 13:28:25 -0500 Subject: [PATCH] Update exception handling for cases without gold timelines This will close Issue #1 --- README.md | 5 +++-- eval_timeline.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5882a19..3f284e5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ ## Evaluation script versioning -#### Current timestamp (YYYY-MM-DD): 2024-02-23 -Update for 2024-02-23 version: Fix `divided by zero exception` Line 405 at `eval_timeline.py`. +#### Current timestamp (YYYY-MM-DD): 2024-03-05 +Update for 2024-03-05 version: Added exceptional case handling for situations where a patient doesn’t have gold standard timelines, and the system erroneously predicts timelines. In such cases, the system will now assign a score of 0 for that patient. This is described in detail in [Issue #1](https://github.com/HealthNLPorg/chemoTimelinesEval/issues/1). +
Update for 2024-02-23 version: Fix `divided by zero exception` Line 405 at `eval_timeline.py`.
Update for 2024-01-16 version: Initial release. #### Notice: diff --git a/eval_timeline.py b/eval_timeline.py index f420114..55f0fab 100644 --- a/eval_timeline.py +++ b/eval_timeline.py @@ -595,8 +595,14 @@ def macro_average_metrics( 1.0, 1.0, and 1.0 for the given patient in local precision, recall, and F1, respectively. """ if len(gold_timeline) == 0: - true_pos, false_pos, false_neg = [], [], [] - p, r, f_score = 1, 1, 1 + if len(pred_timeline) == 0: + true_pos, false_pos, false_neg = [], [], [] + p, r, f_score = 1, 1, 1 + else: + true_pos = [] + false_pos = pred_timeline + false_neg = [] + p, r, f_score = 0, 0, 0 local_relations[pred_patient] = 0 else: logger.info(f"pred_patient ID: {pred_patient}")