Really great question, and one that I find that most people don't really understand on an intuitive level. AUC
is in fact often preferred over accuracy for binary classification for a number of different reasons. First though, let's talk about exactly what AUC
is. Honestly, for being one of the most widely used efficacy metrics, it's surprisingly obtuse to figure out exactly how AUC
works.
AUC
stands for Area Under the Curve
, which curve you ask? Well, that would be the ROC
curve. ROC
stands for Receiver Operating Characteristic, which is actually slightly non-intuitive. The implicit goal of AUC
is to deal with situations where you have a very skewed sample distribution, and don't want to overfit to a single class.
A great example is in spam detection. Generally, spam datasets are STRONGLY biased towards ham, or not-spam. If your data set is 90% ham, you can get a pretty damn good accuracy by just saying that every single email is ham, which is obviously something that indicates a non-ideal classifier. Let's start with a couple of metrics that are a little more useful for us, specifically the true positive rate (TPR
) and the false positive rate (FPR
):
Now in this graph, TPR
is specifically the ratio of true positive to all positives, and FPR
is the ratio of false positives to all negatives. (Keep in mind, this is only for binary classification.) On a graph like this, it should be pretty straightforward to figure out that a prediction of all 0's or all 1's will result in the points of (0,0)
and (1,1)
respectively. If you draw a line through these lines you get something like this:
Which looks basically like a diagonal line (it is), and by some easy geometry, you can see that the AUC
of such a model would be 0.5
(height and base are both 1). Similarly, if you predict a random assortment of 0's and 1's, let's say 90% 1's, you could get the point (0.9, 0.9)
, which again falls along that diagonal line.
Now comes the interesting part. What if we weren't only predicting 0's and 1's? What if instead, we wanted to say that, theoretically we were going to set a cutoff, above which every result was a 1, and below which every result were a 0. This would mean that at the extremes you get the original situation where you have all 0's and all 1's (at a cutoff of 0 and 1 respectively), but also a series of intermediate states that fall within the 1x1
graph that contains your ROC
. In practice you get something like this:
So basically, what you're actually getting when you do an AUC
over accuracy is something that will strongly discourage people going for models that are representative, but not discriminative, as this will only actually select for models that achieve false positive and true positive rates that are significantly above random chance, which is not guaranteed for accuracy.