Shortcuts

torcheval.metrics.functional.multiclass_binned_auroc

torcheval.metrics.functional.multiclass_binned_auroc(input: Tensor, target: Tensor, *, num_classes: int, threshold: Union[int, List[float], Tensor] = 200, average: Optional[str] = 'macro') Tuple[Tensor, 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_binned_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.
  • threshold – A integer 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.2, 0.1], [0.4, 0.2, 0.1], [0.6, 0.1, 0.2], [0.4, 0.2, 0.3], [0.6, 0.2, 0.4]])
>>> target = torch.tensor([0, 1, 2, 1, 0])
>>> multiclass_binned_auroc(input, target, num_classes=3, threshold=5)
tensor(0.4000)
>>> multiclass_binned_auroc(input, target, num_classes=3, threshold=5, average=None)
tensor([0.5000, 0.2500, 0.2500, 0.0000, 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