torchmetrics: [metrics] AUROC Metric can't handle 0 observations of a class with multiclass classifier
I’m attempting to calculate AUROC for a multiclass problem where some classes are very rare, occasionally never seen, and I’m getting the following error: raise ValueError("No positive samples in targets, true positive value should be meaningless")
In the case of 0 observations, I feel the average='weighted'
should work, since the contribution to the final AUROC should be 0 regardless. One can think of other scenarios where there are a very high number of classes, some of which will happen to not be seen in some dataset.
_Originally posted by @BeyondTheProof in https://github.com/PyTorchLightning/pytorch-lightning/issues/2210#issuecomment-872440776_
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (13 by maintainers)
Hi! thanks for your contribution!, great first issue!
I’ve found a hack for this by subclassing AUROC:
I will be making a cleaner fix in torch and asking for a PR