Fix ZeroDivisionError in metric evaluation across examples#384
Fix ZeroDivisionError in metric evaluation across examples#384ARYANPATEL-BIT wants to merge 2 commits intokubeedge:mainfrom
Conversation
Signed-off-by: Aryan Patel <aryan.patel7291@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ARYANPATEL-BIT The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/assign @MooreZheng |
There was a problem hiding this comment.
Code Review
This pull request adds safety checks to prevent ZeroDivisionError in accuracy calculation functions across multiple test environments. The feedback suggests using more idiomatic Python by checking the truthiness of the list directly instead of its length.
examples/cloud-edge-collaborative-inference-for-llm/testenv/accuracy.py
Outdated
Show resolved
Hide resolved
examples/government/singletask_learning_bench/objective/testenv/acc.py
Outdated
Show resolved
Hide resolved
examples/government_rag/singletask_learning_bench/testenv/acc.py
Outdated
Show resolved
Hide resolved
examples/government_rag/singletask_learning_bench/testenv/acc.py
Outdated
Show resolved
Hide resolved
examples/government_rag/singletask_learning_bench/testenv/acc.py
Outdated
Show resolved
Hide resolved
examples/government_rag/singletask_learning_bench/testenv/acc.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Aryan Patel <aryan.patel7291@gmail.com>
Status: Fixed ✅
🎯 Issue Fixed
Fixes #383
🚨 Problem
During metric evaluation, accuracy calculation divides by
len(same_elements). Empty lists from prediction edge-cases causeZeroDivisionErrorand crash the training/evaluation pipeline.📁 Affected Files
examples/llm_simple_qa/testenv/acc.py
examples/government/singletask_learning_bench/objective/testenv/acc.py
examples/government_rag/singletask_learning_bench/testenv/acc.py
examples/cloud-edge-collaborative-inference-for-llm/testenv/accuracy.py
text
🔧 The Fix
Before (CRASH):
After (SAFE):
💾 Complete Fixed Function
✅ Test Cases