def test_auc(x, y, expected, unsqueeze_x, unsqueeze_y): x = tensor(x) y = tensor(y) if unsqueeze_x: x = x.unsqueeze(-1) if unsqueeze_y: y = y.unsqueeze(-1) # Test Area Under Curve (AUC) computation assert auc(x, y, reorder=True) == expected
def compute(self) -> torch.Tensor: preds, targets = self._get_preds_and_targets() if torch.unique(targets).numel() == 1: return torch.tensor(np.nan) prec, recall, _ = precision_recall_curve(preds, targets) return auc(recall, prec) # type: ignore
def test_auc(x, y, expected): # Test Area Under Curve (AUC) computation assert auc(tensor(x), tensor(y), reorder=True) == expected
def test_auc(x, y, expected): # Test Area Under Curve (AUC) computation assert auc(torch.tensor(x), torch.tensor(y)) == expected