Fix dictionary key type mismatch causing KeyError during metrics eval#1337
Fix dictionary key type mismatch causing KeyError during metrics eval#1337abhayrajjais01 wants to merge 1 commit intoweecology:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1337 +/- ##
=======================================
Coverage 87.34% 87.34%
=======================================
Files 24 24
Lines 2978 2978
=======================================
Hits 2601 2601
Misses 377 377
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
58c66e4 to
0390dd8
Compare
0390dd8 to
d45bfb4
Compare
|
I’m trying to understand this bug quickly. Could you explain how you discovered it? If you used AI, that’s totally fine. It would help if you could share the script you were running or a small example that reproduces the issue. Typically, we ask contributors to first open an issue so we can reproduce the bug and then give a formal go-ahead for a PR. This helps us better understand and track the problem. |
henrykironde
left a comment
There was a problem hiding this comment.
Thanks @abhayrajjais01 for the bug report. Please provide script to reproduce the bug
Description
This PR fixes a bug in
src/deepforest/metrics.pywhere evaluating predictions resulted in aKeyErrordue to dictionary type mismatches.Changes:
RecallPrecision.compute()method, thenumeric_to_label_dictgeneration now casts the keys (thenumericvalue fromlabel_dict) toint.label_dictcontained string-based integer values (e.g.{"Tree": "0"}), the model outputs (which are proper integers) failed to map backward to their corresponding labels during the evaluation metrics calculation.Type of change
Related Issue
closes #1344
AI-Assisted Development