Rationale of using AUC?

Especially in the computer-science oriented side of the machine learning literature, AUC (area under the receiver operator characteristic curve) is a popular criterion for evaluating classifiers. What are the justifications for using the AUC? E.g. is there a particular loss function for which the optimal decision is the classifier with the best AUC?

• AUC is a loss function, it is clear that for this loss function the optimal decision is the classifier with the best AUC. – robin girard Jun 5 '11 at 19:23
• @robingirard No it's not, since it's not differentiable, i.e. you can't optimize it directly. – cpury Jun 22 '18 at 15:20

For binary classifiers $C$ used for ranking (i.e. for each example $e$ we have $C(e)$ in the interval $[0, 1]$) from which the AUC is measured the AUC is equivalent to the probability that $C(e_1) > C(e_0)$ where $e_1$ is a true positive example and $e_0$ is a true negative example. Thus, choosing a model with the maximal AUC minimizes the probability that $C(e_0) \geq C(e_1)$. That is, minimizes the loss of ranking a true negative at least as large as a true positive.
In the example you can observe that while picking up 70% good tomato, black curve picked up around 48% of bad ones (impurity), but blue one has 83% bad ones (impurity). So black curve has better AUC score compared to blue one. 