快捷方式

torcheval.metrics.functional.multiclass_binned_auroc

torcheval.metrics.functional.multiclass_binned_auroc(input: Tensor, target: Tensor, *, num_classes: int, threshold: int | List[float] | Tensor = 200, average: str | None = 'macro') Tuple[Tensor, Tensor]

计算多类别分类的 AUROC,它是 ROC 曲线下的面积。其类版本为 torcheval.metrics.MulticlassAUROC

参数:
  • input (Tensor) – 标签预测的张量,应为形状为 (n_sample, n_class) 的概率或 logits。

  • target (Tensor) – 形状为 (n_samples, ) 的真实标签张量。

  • num_classes (int) – 类别数量。

  • threshold – 表示 bin 数的整数,阈值列表或阈值张量。

  • average (str, optional) –

    • 'macro' [默认]

      分别计算每个类别的指标,并返回它们的未加权平均值。

    • None:

      分别计算每个类别的指标,并返回每个类别的指标。

示例

>>> import torch
>>> from torcheval.metrics.functional import multiclass_binned_auroc
>>> input = torch.tensor([[0.1, 0.1, 0.1, 0.1], [0.5, 0.5, 0.5, 0.5], [0.7, 0.7, 0.7, 0.7], [0.8, 0.8, 0.8, 0.8]])
>>> target = torch.tensor([0, 1, 2, 3])
>>> multiclass_auroc(input, target, num_classes=4, threshold = 5)
0.5
>>> multiclass_binned_auroc(input, target, num_classes=4, threshold = 5, average=None)
tensor([0.0000, 0.3333, 0.6667, 1.0000])

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并获得问题的解答

查看资源