Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError cumulative_true_positives[class_id] #368

Open
d-simple opened this issue Dec 15, 2020 · 1 comment
Open

KeyError cumulative_true_positives[class_id] #368

d-simple opened this issue Dec 15, 2020 · 1 comment
Labels

Comments

@d-simple
Copy link

In ssd300_evaluation.ipynb when running evaluation
with custom/cut dataset there can be zero predictions for specific class which results in KeyError on line

average_precision_evaluator.py
...
def compute_precision_recall(...)
...
tp = self.cumulative_true_positives[class_id] 

This is because match_predictions function skips adding zero-prediction classes to the self.cumulative_true_positives list.
The function has conditional block

if len(predictions) == 0:
    print("No predictions for class {}/{}".format(class_id, self.n_classes))
    true_positives.append(true_pos)
    false_positives.append(false_pos)
    continue

that should resolve the issue but it does so incompletely.

Fixing it like so

if len(predictions) == 0:
    print("No predictions for class {}/{}".format(class_id, self.n_classes))
    true_positives.append(true_pos)
    false_positives.append(false_pos)
    
    cumulative_true_pos = np.cumsum(true_pos)
    cumulative_false_pos = np.cumsum(false_pos)

    cumulative_true_positives.append(cumulative_true_pos)
    cumulative_false_positives.append(cumulative_false_pos)
    continue

resolves the issue (but does not help your model :)

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant