From 03b1afe82c60eb8e94c198b30e26d4ab1454e44f Mon Sep 17 00:00:00 2001 From: Elijas <4084885+Elijas@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:13:15 +0200 Subject: [PATCH] feat(accuracy_tests): print nice table summary --- tests/accuracy/structure_and_text/summarize_results.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/accuracy/structure_and_text/summarize_results.py b/tests/accuracy/structure_and_text/summarize_results.py index b9bfa06..c4667c7 100644 --- a/tests/accuracy/structure_and_text/summarize_results.py +++ b/tests/accuracy/structure_and_text/summarize_results.py @@ -40,7 +40,8 @@ def main(): ), f"missing '{report.actual_structure_and_text_summary.name}' for '{report.identifier}'" with report.actual_structure_and_text_summary.open("r") as file: summary_data = json.load(file) - metrics = summary_data["metrics"] + metrics = summary_data["metrics"].copy() + metrics["identifier"] = report.identifier all_metrics.append(metrics) # STEP: Aggregate the metrics @@ -92,7 +93,11 @@ def main(): summary["total_unexpected"][element_type] += count # STEP: Show and save the summary - print("# Selected filings:", [r.identifier for r in filings]) + print("# Selected filings | F1-score | Recall | Precision") + for m in all_metrics: + print( + f"{m['identifier']:>33} | {m['f1_score']:>8} | {m['recall']:>7} | {m['precision']:>7}" + ) print( "# Summary:", json.dumps(summary, indent=4, sort_keys=False, ensure_ascii=False),