Why is "micro" not in "allowed average" in AUROC? #730
-
|
Documentation at AUROC shows that "micro" can be used on average https://torchmetrics.readthedocs.io/en/stable/references/modules.html#f1
So, I initialized AUROC in my code in this way
but I got this error message
When I check AUROC code, I notice that "micro" is not in "allowed_average" https://github.com/PyTorchLightning/metrics/blob/master/torchmetrics/classification/auroc.py I am not sure if it is a documentation error or developed functionality missing from the AUROC code. I use conda torchmetrics version (0.6.2) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
I do not get the error you are mentioning when running locally. |
Beta Was this translation helpful? Give feedback.
-
|
@JoeNatan30 — this was a bug in torchmetrics 0.6.x. Fully resolved now. Current usage (v1.9.0): from torchmetrics.classification import MulticlassAUROC
auroc = MulticlassAUROC(
num_classes=NUM_CLASSES,
average="macro", # "macro", "weighted", or "none"
thresholds=None,
)
score = auroc(preds, target)Important: If you need micro-averaged AUROC, convert to multilabel: from torchmetrics.classification import MultilabelAUROC
import torch.nn.functional as F
target_onehot = F.one_hot(target, num_classes=NUM_CLASSES)
auroc = MultilabelAUROC(num_labels=NUM_CLASSES, average="micro")
score = auroc(preds, target_onehot)Docs: AUROC |
Beta Was this translation helpful? Give feedback.
@JoeNatan30 — this was a bug in torchmetrics 0.6.x. Fully resolved now.
Current usage (v1.9.0):
Important:
average="micro"is intentionally not supported for multiclass AUROC — it doesn't have a standard definition for the one-vs-rest case. The scikit-learn docs note this same subtlety.If you need micro-averaged AUROC, convert to multilabel: