Shortcuts

torcheval.metrics.functional.multiclass_binned_auroc

torcheval.metrics.functional.multiclass_binned_auroc(input: Tensor, target: Tensor, *, num_classes: int, threshold: int | List[float] | Tensor = 200, average: str | None = 'macro') Tuple[Tensor, Tensor]

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

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.

  • threshold – A integeter representing number of bins, a list of thresholds, or a tensor of thresholds.

  • 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_binned_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, threshold = 5)
0.5
>>> multiclass_binned_auroc(input, target, num_classes=4, threshold = 5, 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