fix(metrics): separate threshold precision from the AP envelope
Merged
AF
2h ago+70+70+01234567890123456789-3-3-0123456789
Summary
Fixed-confidence detection precision currently uses the interpolated precision envelope intended for average precision. This lets correct predictions below the selected score threshold inflate the reported precision and F1 for detections above it.
For example, with a high-confidence false positive followed by true positives at scores 0.8 and 0.05, threshold 0.1 accepts one true positive and one false positive. Precision should be 1/2, but the AP envelope makes it 2/3.
Compute fixed-threshold precision from the actual cumulative TP/FP counts, then construct the interpolated envelope only for AP. Recall, detection matching and AP remain unchanged.
Validation
- Added 13 native
get_metricscases: 7 fail and 6 pass on the unchanged base; all 13 pass with this fix. - Hand-calculated precision, recall, F1 and AP cover six thresholds, exact-score boundaries, two input orderings and two-class macro averaging.
- The AP checks remain identical at every confidence threshold.
- Ruff 0.15.10 check/format and
git diff --checkpass. The full optional-dependency suite was not run.
Checklist
- Added regression tests for corrected precision/F1 and unchanged AP.
- Kept detection matching and IoU thresholds unchanged.
- Apply the
buglabel.