torcheval.metrics.functional.binary_precision_recall_curve¶
- torcheval.metrics.functional.binary_precision_recall_curve(input: Tensor, target: Tensor) Tuple[Tensor, Tensor, Tensor] ¶
返回二分类任务的精确率-召回率对及其对应的阈值。如果目标张量中缺少某个类别,则其召回率值设置为 1.0。
其类版本为
torcheval.metrics.BinaryPrecisionRecallCurve
。- 参数:
input (Tensor) – 标签预测的张量,应为形状为 (n_sample, ) 的概率或 logits。
target (Tensor) – 形状为 (n_samples, ) 的真实标签张量。
- 返回值:
precision (Tensor): 精确率结果张量。其形状为 (n_thresholds + 1, )
recall (Tensor): 召回率结果张量。其形状为 (n_thresholds + 1, )
thresholds (Tensor): 阈值张量。其形状为 (n_thresholds, )
- 返回类型:
元组
示例
>>> 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]))