Understanding the ROC AUC calculator — concept and principle
The area under the ROC curve (AUC) summarises how well a model's scores rank positive cases above negative ones, across every possible decision threshold. Enter the model's predicted scores and the true 0/1 labels, and the calculator returns the AUC and the Gini coefficient. It is widely used for credit scoring, medical tests and any classifier that outputs a score or probability.
How it is calculated
- Split the scores into positives (label 1) and negatives (label 0).
- Compare every positive with every negative: count 1 if the positive scores higher, ½ if they tie, 0 otherwise.
- AUC = total count ÷ (number of positives × number of negatives).
- Gini = 2 × AUC − 1.
Scores only need to be comparable; they do not have to be probabilities, and any strictly increasing transformation leaves the AUC unchanged.
The principle
The ROC curve plots the true positive rate against the false positive rate as the threshold moves from high to low. Its area has a neat meaning: it equals the probability that a randomly chosen positive gets a higher score than a randomly chosen negative. That is exactly the Mann-Whitney U statistic divided by the number of pairs, which is why counting pairs gives the same answer as integrating the curve. Because it uses only the order of scores, AUC measures ranking quality, not calibration.
Worked example
- Positives (label 1): 0.9, 0.8, 0.6, 0.4. Negatives (label 0): 0.7, 0.55, 0.3, 0.2. That gives 4 × 4 = 16 pairs.
- 0.9 beats all 4 negatives; 0.8 beats all 4; 0.6 beats 0.55, 0.3 and 0.2 (3); 0.4 beats 0.3 and 0.2 (2).
- Total = 4 + 4 + 3 + 2 = 13, so AUC = 13 ÷ 16 = 0.8125.
- Gini = 2 × 0.8125 − 1 = 0.625.
How to read the result
AUC = 0.5 means the scores rank no better than chance, 1.0 means every positive outranks every negative, and values below 0.5 mean the ranking is reversed. Rough conventions call 0.7–0.8 acceptable and 0.8–0.9 good, but the useful level depends on the field. With very few cases, as here, AUC is unstable: moving one score can change it by a sixteenth.
Common mistakes
- Feeding hard 0/1 predictions instead of scores, which collapses the curve to a single point.
- Assuming a high AUC means well-calibrated probabilities.
- Relying on AUC for heavily imbalanced data where precision matters; a precision-recall curve is often more informative there.
Frequently asked questions
Why is Gini equal to 2 × AUC − 1?
It rescales AUC so that chance is 0 and perfect ranking is 1; in credit scoring this is also called the accuracy ratio.
How are ties handled?
Each tied positive-negative pair counts as half a win, which matches the trapezoidal area under the ROC curve.
Can I compute AUC for more than two classes?
Yes, by averaging one-versus-rest or one-versus-one AUCs, but this calculator handles the binary case.
Sources: J. A. Hanley and B. J. McNeil, The meaning and use of the area under a receiver operating characteristic (ROC) curve, Radiology, 1982 · T. Fawcett, An introduction to ROC analysis, Pattern Recognition Letters, 2006