# Exchange the x-axis and y-axis in order to flip ROC curve

I have a continuous variable X and a binary response outcome D. The ROC curve I got for D with respect to X is below the diagonal line, as shown in the following picture.

In this ROC curve, the true positive rate(y-axis) is defined as P{X>c|D=1}, and the false positive rate(x-axis) is P{X>c|D=0}.

I want to flip the ROC curve. The true positive rate should be changed to P{X>c|D=0}, and the false positive rate should be changed to P{X>c|D=1}. Could I exchange the x-axis and y-axis in order to flip the ROC curve?

NO

The area under the ROC curve is related to the separation between the predicted outputs, often probability values.

If you just swap the group labels, you do not affect the separation, so the area under the ROC curve should be the same. However, flipping the axes changes the area under your curve.

• I think the correct transformation is $(x,y)\rightarrow (1-y,1-x)$, not $(x,y)\rightarrow (y,x)$, and I will edit this into the answer (probably with some pictures) once I have an opportunity to verify.
– Dave
Aug 1, 2022 at 11:18

When your ROC curve is below the diagonal line, and your AUC is < 0.5, this means that your classifier is worse than random. In other words, it works well, but wrong.

What you want is actually to swap your definition of a positive case, so that instead of saying an observations is positive when X > c, and negative when X <= c, it becomes positive when X <= c, and negative when X > c.

As a consequence, the true positive rate is now defined as P(X<=c|D=1), and the false positive rate is P{X<=c|D=0}.

Not only will your ROC curve flip above the line, but your classifier will make much more sense as well.