Shortcuts

torcheval.metrics.functional.binary_recall

torcheval.metrics.functional.binary_recall(input: Tensor, target: Tensor, *, threshold: float = 0.5) Tensor[source]

Compute recall score for binary classification class, which is calculated as the ratio between the number of true positives (TP) and the total number of actual positives (TP + FN). Its class version is torcheval.metrics.BinaryRecall. See also multiclass_recall

Parameters:
  • input (Tensor) – Tensor of the predicted labels/logits/probabilities, with shape of (n_sample, ).
  • target (Tensor) – Tensor of ground truth labels with shape of (n_sample, ).
  • threshold (float, default 0.5) – Threshold for converting input into predicted labels for each sample. torch.where(input < threshold, 0, 1) will be applied to the input.

Examples:

>>> import torch
>>> from torcheval.metrics.functional.classification import binary_recall
>>> input = torch.tensor([0, 0, 1, 1])
>>> target = torch.tensor([0, 1, 1, 1])
>>> binary_recall(input, target)
tensor(0.6667)  # 2 / 3
>>> input = torch.tensor([0, 0.2, 0.4, 0.7])
>>> target = torch.tensor([1, 0, 1, 1])
>>> binary_recall(input, target)
tensor(0.3333)  # 1 / 3
>>> binary_recall(input, target, threshold=0.4)
tensor(0.5000)  # 1 / 2

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