MCPcopy Create free account
hub / github.com/twitter/the-algorithm-ml / test_auc

Function test_auc

core/test_metrics.py:116–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114
115
116def test_auc():
117 num_samples = 10000
118 metric = core_metrics.Auc(num_samples)
119 target = torch.tensor([0, 0, 1, 1, 1])
120 preds_correct = torch.tensor([-1.0, -1.0, 1.0, 1.0, 1.0])
121 outputs_correct = {"logits": preds_correct, "labels": target}
122 preds_bad = torch.tensor([1.0, 1.0, -1.0, -1.0, -1.0])
123 outputs_bad = {"logits": preds_bad, "labels": target}
124
125 metric.update(outputs_correct)
126 assert metric.compute().item() == 1.0
127
128 metric.reset()
129 metric.update(outputs_bad)
130 assert metric.compute().item() == 0.0
131
132
133def test_pos_rank():

Callers

nothing calls this directly

Calls 3

updateMethod · 0.45
computeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected