Shortcuts

torcheval.metrics.functional.multiclass_auroc

torcheval.metrics.functional.multiclass_auroc(input: Tensor, target: Tensor, *, num_classes: int, average: Optional[str] = 'macro') Tensor[source]

Compute AUROC, which is the area under the ROC Curve, for multiclass classification. Its class version is torcheval.metrics.MulticlassAUROC. See also binary_auroc

Parameters:
  • input (Tensor) – Tensor of label predictions It should be probabilities or logits with shape of (n_sample, n_class).
  • target (Tensor) – Tensor of ground truth labels with shape of (n_samples, ).
  • num_classes (int) – Number of classes.
  • average (str, optional) –
    • 'macro' [default]:
      Calculate metrics for each class separately, and return their unweighted mean.
    • None:
      Calculate the metric for each class separately, and return the metric for every class.

Examples:

>>> import torch
>>> from torcheval.metrics.functional import multiclass_auroc
>>> input = torch.tensor([[0.1, 0.1, 0.1, 0.1], [0.5, 0.5, 0.5, 0.5], [0.7, 0.7, 0.7, 0.7], [0.8, 0.8, 0.8, 0.8]])
>>> target = torch.tensor([0, 1, 2, 3])
>>> multiclass_auroc(input, target, num_classes=4)
0.5
>>> multiclass_auroc(input, target, num_classes=4, average=None)
tensor([0.0000, 0.3333, 0.6667, 1.0000])

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources