Removed non-determenistic behavior from match_detections
The main change is in brambox/boxes/statistics/util.py
, but I also removed some unused imports and fixed linting errors in brambox/boxes/statistics/pr.py
. I can remove that if you want.
The main change prevents a non-deterministic corner case in match_detections
. Previously if positives had confidence scores that tied, it might be sorted like this:
positives = [
(1.0, True),
(1.0, False),
(0.5, True),
]
or like this:
positives = [
(1.0, False),
(1.0, True),
(0.5, True),
]
which ultimately changes the PR curve and computed AP values. My change ensures that False
values always before after True
values with the same confidence. This will cause a slight bias towards lower scores, but (1) I think it is reasonable to assume the worst case when computing metrics and (2) this case wont show up very often. However, I did run into an example where true and false positive detections all had confidences of 1.0 due to clipping behavior, so I think it it should be handled.