Shortcuts

torcheval.metrics.functional.binary_precision_recall_curve

torcheval.metrics.functional.binary_precision_recall_curve(input: Tensor, target: Tensor) Tuple[Tensor, Tensor, Tensor][source]

Returns precision-recall pairs and their corresponding thresholds for binary classification tasks. If a class is missing from the target tensor, its recall values are set to 1.0.

Its class version is torcheval.metrics.BinaryPrecisionRecallCurve. See also multiclass_precision_recall_curve, multilabel_precision_recall_curve

Parameters:
  • input (Tensor) – Tensor of label predictions It should be probabilities or logits with shape of (n_sample, ).
  • target (Tensor) – Tensor of ground truth labels with shape of (n_samples, ).
Returns:

  • precision (Tensor): Tensor of precision result. Its shape is (n_thresholds + 1, )
  • recall (Tensor): Tensor of recall result. Its shape is (n_thresholds + 1, )
  • thresholds (Tensor): Tensor of threshold. Its shape is (n_thresholds, )

Return type:

Tuple

Examples:

>>> import torch
>>> from torcheval.metrics.functional import binary_precision_recall_curve
>>> input = torch.tensor([0.1, 0.5, 0.7, 0.8])
>>> target = torch.tensor([0, 0, 1, 1])
>>> binary_precision_recall_curve(input, target)
(tensor([0.5000, 0.6667, 1.0000, 1.0000, 1.0000]),
tensor([1.0000, 1.0000, 1.0000, 0.5000, 0.0000]),
tensor([0.1000, 0.5000, 0.7000, 0.8000]))

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