Skip to content

Refactor metrics.prep_preds function

Najam Syed requested to merge fix_prep_preds into master

@christopher.funk @benjamin.pikus

This MR refactors the prep_preds() function in metrics.py to generate the output dict of predictions (where each dict key is a class name and each dict value is a list of dicts corresponding to predictions) in a single pass instead of iterating over class names, file ids, and predictions in quadruple nested for loops (where the fourth is a list comprehension).

Given n predictions, c class names, and f file ids, this reduces the runtime complexity from roughly O(n^2 * c * f) to O(n), excluding list sorting for each class's predictions.

Edited by Najam Syed

Merge request reports