torcheval.metrics.functional.multilabel_recall_at_fixed_precision¶
-
torcheval.metrics.functional.
multilabel_recall_at_fixed_precision
(input: Tensor, target: Tensor, *, num_labels: int, min_precision: float) Tuple[List[Tensor], List[Tensor]] [source]¶ Returns the highest possible recall value give the minimum precision for each label and their corresponding thresholds for multi-label classification tasks. The maximum recall computation for each label is equivalent to _binary_recall_at_fixed_precision_compute in binary_recall_at_fixed_precision.
Its class version is
torcheval.metrics.MultilabelRecallAtFixedPrecision
. See alsobinary_recall_at_fixed_precision
Parameters: - input (Tensor) – Tensor of label predictions It should be probabilities with shape of (n_samples, n_label)
- target (Tensor) – Tensor of ground truth labels with shape of (n_samples, n_label)
- num_labels (int) – Number of labels
- min_precision (float) – Minimum precision threshold
Returns: - List[torch.Tensor], thresholds: List[torch.Tensor])
recall: List of max recall values for each label thresholds: List of best threshold values for each label
Return type: a tuple of (recall
Examples
>>> import torch >>> from torcheval.metrics.functional import multilabel_recall_at_fixed_precision >>> input = torch.tensor([[0.75, 0.05, 0.35], [0.45, 0.75, 0.05], [0.05, 0.55, 0.75], [0.05, 0.65, 0.05]]) >>> target = torch.tensor([[1, 0, 1], [0, 0, 0], [0, 1, 1], [1, 1, 1]]) >>> multilabel_recall_at_fixed_precision(input, target, num_labels=3, min_precision=0.5) ([tensor([1.0, 1.0, 1.0], tensor([0.05, 0.55, 0.05])])