-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Classification metrics overhaul: accuracy metrics (2/n) #4838
Classification metrics overhaul: accuracy metrics (2/n) #4838
Conversation
Hello @tadejsv! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-12-21 13:07:13 UTC |
yes, it ready, let me check why it cannot be merged... |
3bf3c3a
@tadejsv mind rebase on |
@Borda approvals still seems to be dismissed by new commits |
@Borda I already rebased (and I did it again right now). The problem is that I rebased to master in the time period between when 1.2-dev branch was created, and when it was announced in the slack channel. In my opinion that branch should have been rebased to master right before it was announced. It doesn't contain, for example, PR #5134, which is "accidentally" picked up in this PR. If I remove this then tests here will fail, if I disabled DDP tests then another PR will be needed once 1.2-dev is rebased on master to re-enable these tests... |
I know, I am pushing @williamFalcon as I can... @edenlightning @tchaton |
@tadejsv it seems we resolved the issue with dismissed approvals, but mind resolve conflicts with |
@Borda conflicts resolved, we're ready to go :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment. Else LGTM. Nice work!!
This is the case for binary and multi-label logits. | ||
|
||
If preds has an extra dimension as in the case of multi-class scores we perform an argmax on ``dim=1``. | ||
Accepts all input types listed in :ref:`metrics:Input types`. | ||
|
||
Args: | ||
threshold: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering, should threshold be None too by default?? because it's not used when we provider pred_labels, and use 0.5 by default when we have pred_probs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess this could be done - but in a way that if pred_probs are passed in, None would default to 0.5. otherwise this would be a very disturbing breaking change for people used to using accuracy without extra params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's what meant here 0.5 by default when we have pred_probs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, will add this in the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great ! minor comments
tensor(0.6667) | ||
""" | ||
|
||
if top_k is not None and top_k <= 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test top_k is not a float.
return {'tps': tps, 'sups': sups} | ||
return class_reduce(tps, sups, sups, class_reduction=class_reduction) | ||
|
||
|
||
def _confmat_normalize(cm): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we provide the normalisation dimension ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some people like to visualise both matrices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand. If you are speaking about the confusion matrix - that is not part of this PR (this one is about the accuracy metric).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, wait with merge to after release branch gets synced with master tomorrow. Then this PR just needs to updated such that the fix from #5134 is not part of it anymore.
Oh sorry @SkafteNicki, I didn't have your message when I merged. I refreshed the page and saw it. |
@tchaton no probs. What should we do about it? Solve merge conflicts when |
This PR is a spin-off from #4835.
What does this PR do?
Metrics (changes and additions)
The metrics below are based on the new input formatting function from #4837
Accuracy
The accuracy metric now get a new
subset_accuracy
parameter, to calculate subset accuracy in case of multi-label or multi-dimensional multi-class inputs. This parameter is set toFalse
by default, which preserves the default behavior of the old metric.Additionally, a
top_k
parameter enables it to be used as TopK accuracy for multi-class inputs (with probabilities) - thanks @rohitgr7 . Thetop_k
format does not yet have an equivalent in sklearn (will in 0.24).HammingDistance (new)
This is equivalent to
hamming_loss
from sklearn.