# Why is the ROC curve of a random classifier the line $\text{FPR}=\text{TPR}$?

The title is my whole question. FPR is the false positive rate. TPR is the true positive rate.

If you classify a fraction $k$ of your cases as positive then, because of the randomness, the same fraction $k$ of cases which should be positive will be classified positive (true positives), and the same fraction $k$ of cases which should be negative will be classified positive (false positives).

So the true positive rate and the false positive rate are the same.

• can you possibly write that with probabilistic statements? May 29, 2018 at 18:59
• @ℕʘʘḆḽḘ Call $T$ the event that a case is actually positive and $R$ the event that it is predicted to be positive with this random predictor. Then $\mathbb P(R \mid T) = k = \mathbb P(R \mid T^{c})$ May 29, 2018 at 20:30
• thanks sure but I mean could you explain how you derive this result? May 29, 2018 at 20:42
• @ℕʘʘḆḽḘ "a random classifier" is stated in the title, so the probability of being predicted positive does not depend on any property of the event May 29, 2018 at 20:50

# Identity

Let $$T$$ be the event that a case is positive, and $$R$$ the event a case is predicted to be positive by a classifier.

Since $$T$$ and $$T^c$$ are mutually exclusive and collectively exhaustive, we can decompose $$\mathbb{P}(R)$$ as follows:

$$\begin{split} \mathbb{P}(R) & = \mathbb{P}(R|T)\mathbb{P}(T)+\mathbb{P}(R|T^c)\mathbb{P}(T^c)\\ & = \mathbb{P}(R|T)(1-\mathbb{P}(T^c))+\mathbb{P}(R|T^c)\mathbb{P}(T^c)\\ & = [\mathbb{P}(R|T^c)-\mathbb{P}(R|T)]\mathbb{P}(T^c)+\mathbb{P}(R|T). \end{split}$$

The identity $$\mathbb{P}(R)-\mathbb{P}(R|T) = [\mathbb{P}(R|T^c)-\mathbb{P}(R|T)]\mathbb{P}(T^c),$$ means that $$\mathbb{P}(R)-\mathbb{P}(R|T) = 0$$ if and only if $$\mathbb{P}(R|T^c)-\mathbb{P}(R|T)=0$$, for $$\mathbb{P}(T^c)>0$$.

# Random guessing

To begin, inspect the left-hand side condition: $$\mathbb{P}(R)=\mathbb{P}(R|T)$$. This condition implies the independence between events $$R$$ and $$T$$. A classifier that is based on random guessing has to satisfy this condition.

Suppose the classifier is random guessing but it does not satisfy the left-hand side condition, i.e. $$\mathbb{P}(R)\ne\mathbb{P}(R|T)$$. Then, the guesses are biased for cases that are in $$T$$, i.e. the classifier guesses differently when encountering a positive case. This contradicts the notion of a random guess.

In other words, if the classifier is random guessing unconditionally, or conditionally on positive cases, it should perform equally well in both cases.

# Line y = x

Next, inspect the right-hand side condition: $$\mathbb{P}(R|T)=\mathbb{P}(R|T^c)$$. This condition means that the true-positive rate equals to the false-positive rate. Geometrically, the line $$y=x$$ on the ROC graph represents this right-hand side condition. This is because, the ROC graph y-axis and x-axis represent the true-positive rate and false-positive rate respectively.

# Equivalance

To conclude, the left-hand side condition represents a random-guessing classifier, and the right-hand side condition represents the line $$y=x$$. They are in fact equivalent.