Shortcuts

torcheval.metrics.functional.binary_binned_auroc

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

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

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 integer representing number of bins, a list of thresholds, or a tensor of thresholds. The same thresholds will be used for all tasks. If threshold is a tensor, it must be 1D. If list or tensor is given, the first element must be 0 and the last must be 1.

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_binned_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