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

Bug in average_precision Metric #2315

Closed
elias-ramzi opened this issue Jun 22, 2020 · 4 comments
Closed

Bug in average_precision Metric #2315

elias-ramzi opened this issue Jun 22, 2020 · 4 comments
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@elias-ramzi
Copy link
Contributor

🐛 Bug

Hi everyone, I encountered a bug when using the average_precision metric (pytorch_lightning.metrics.functional.classification). It yields incorrect results (negative ones).

There seems to be a missing parenthesis in the code here :

https://github.com/PyTorchLightning/pytorch-lightning/blob/master/pytorch_lightning/metrics/functional/classification.py#L847

It works when corrected as :

return -torch.sum((recall[1:] - recall[:-1]) * precision[:-1])

In order to reproduce negative results :

import torch
import pytorch_lightning.metrics.functional.classification as M

torch.manual_seed(23)
truth = (torch.rand(100) > .6)
pred = torch.rand(100)

M.average_precision(pred, truth)

I did not find an issue on this topic yet. If needed I can submit a PR.

Thanks ☺️

@elias-ramzi elias-ramzi added bug Something isn't working help wanted Open to be worked on labels Jun 22, 2020
@github-actions
Copy link
Contributor

Hi! thanks for your contribution!, great first issue!

@InCogNiTo124
Copy link
Contributor

I'd like to fix it

@elias-ramzi
Copy link
Contributor Author

Hi, I have already created a branch for the PR !

@edenlightning
Copy link
Contributor

Thanks for the issue and the fix! @InCogNiTo124 Just saying- there are many other open issues if you want to take a stab at :)

@Borda Borda closed this as completed Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

4 participants