Log loss and ROC AUC
Quick answer
Log loss evaluates probability quality while ROC-AUC evaluates ranking across positive-negative pairs. A model can have excellent ranking and poor probability estimates, so neither score substitutes for the other. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Equal ranking, different probability loss
from sklearn.metrics import log_loss,roc_auc_scorey=[0,1]for p in [[.2,.8],[.49,.51]]: print(f"{log_loss(y,p,labels=[0,1]):.3f} {roc_auc_score(y,p):.3f}")Observed local output:
0.223 1.0000.673 1.000Both rankings are perfect but probability confidence differs.
How it works
For binary label y and positive probability p, log loss is the mean of -[y log(p)+(1-y) log(1-p)] using natural logarithms. A confident wrong prediction incurs large loss. Specify the label order for probability columns; scikit-learn clips probabilities using dtype precision to avoid log(0). For multiclass, select the probability of the true class and average its negative log. ROC plots true positive rate against false positive rate across score thresholds. ROC-AUC equals the probability a random positive outranks a random negative, giving tied pairs half credit. It is undefined when either class is absent; report null rather than inventing a score. AUC is unchanged by strictly increasing score transformations, whereas log loss generally changes. ROC-AUC does not measure calibration, workload or performance at a specific threshold. For multiclass ROC-AUC, specify one-vs-rest or one-vs-one and averaging. Use paired uncertainty estimates for comparisons on the same examples.
Half credit for tied scores
from sklearn.metrics import roc_auc_scorey=[1,1,0,0];s=[3,2,2,1]print(roc_auc_score(y,s))Observed local output:
0.875Three wins and one tie across four positive-negative pairs yield 3.5/4.
Common mistakes
Do not feed hard predictions to log loss as if calibrated probabilities, apply a threshold before computing AUC, or ignore ties and absent classes. AUC does not imply good precision for rare events.
Practice and next steps
Compare probabilities [0.2,0.8] with [0.49,0.51] for truth [0,1]. Explain why AUC agrees while log loss differs. Complete the knowledge check and staged exercise. Next: Precision recall and average precision.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Log loss and ROC AUC — knowledge check
Apply log loss and roc auc to new scenarios.
Which transformation preserves AUC?
What is a tied pair worth?
Which loss penalizes overconfident wrong probabilities?
What if there are no positives?
Does high AUC guarantee good calibration?