ROC AUC summarises how well a model ranks positives above negatives, across every possible threshold. It has a neat probabilistic meaning:
AUC is the probability that a randomly chosen positive gets a higher score than a randomly chosen negative.
So you can compute it by comparing every (positive, negative) pair: count 1 when the positive scores higher, 0.5 when they tie, and divide by the number of pairs.
Implement roc_auc(y_true, scores), where y_true contains 0s and 1s. If there are no positives or no negatives, AUC is undefined, so return float("nan").
Example
roc_auc([0, 0, 1, 1], [0.1, 0.4, 0.35, 0.8]) # 0.75