Shortcuts

torcheval.metrics.functional.binary_binned_auroc

torcheval.metrics.functional.binary_binned_auroc(input: Tensor, target: Tensor, *, num_tasks: int = 1, threshold: int | List[float] | Tensor = 200) Tuple[Tensor, Tensor]

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

Parameters:
  • input (Tensor) – Tensor of label predictions It should be predicted label, probabilities or logits with shape of (num_tasks, n_sample) or (n_sample, ).

  • target (Tensor) – Tensor of ground truth labels with shape of (num_tasks, n_sample) or (n_sample, ).

  • num_tasks (int) – Number of tasks that need binary_binned_auroc calculation. Default value is 1. binary_binned_auroc for each task will be calculated independently.

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

Examples:

>>> import torch
>>> from torcheval.metrics.functional import binary_binned_auroc
>>> input = torch.tensor([0.1, 0.5, 0.7, 0.8])
>>> target = torch.tensor([1, 0, 1, 1])
>>> binary_binned_auroc(input, target, threshold=5)
(tensor(0.5)
tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000]))

>>> input = torch.tensor([0.1, 0.5, 0.7, 0.8])
>>> target = torch.tensor([1, 0, 1, 1])
>>> threshold = tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000])
>>> binary_binned_auroc(input, target, threshold=threshold)
(tensor(0.5)
tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000]))

>>> input = torch.tensor([[1, 1, 1, 0], [0.1, 0.5, 0.7, 0.8]])
>>> target = torch.tensor([[1, 0, 1, 0], [1, 0, 1, 1]])
>>> binary_auroc(input, target, num_tasks=2, threshold=5)
(tensor([0.7500, 0.5000],
tensor([0.0000, 0.2500, 0.5000, 0.7500, 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