Probability of error for consistent classifier (Random Forests) I'm going through the paper "Consistency of Random Forests and Other Averaging Classifiers" and I'm stuck on a seemingly simple part of the proof for Proposition 1.
Here's the relevant part:

What I'm not getting is the last sentence which claims that 
$$
P(g_n(X, Z) \neq Y | X=x) = (2\eta(x) - 1) P(g_n(x, Z) = 0 + 1 - \eta(x))
\tag{a}\label{a}
$$
Further up the authors define $\eta(x) = P(Y = 1|X=x)$
My assumption is that 
$$
P(g_n(X, Z) \neq Y | X=x) = P(g_n(X, Z) = 1 |Y=0, X=x) + P(g_n(X, Z) = 0 | Y=1, X=x)
$$
i.e. the probability of the classifier $g_n$ being wrong is the probability of predicting one when the true value is zero, plus the probability of predicting zero when the true value is one.
We know that $\eta(x) = P(Y = 1|X=x)$ so $P(Y = 0|X=x) = 1 - \eta(x)$
I still don't see how one arrives at $\ref{a}$ though.
 A: I guess there is a mistake here, it is supposed to be:
$$
P(g_n(X, Z) \neq Y | X=x) = P(g_n(X, Z) = 1 ,Y=0| X=x) + P(g_n(X, Z) = 0 , Y=1| X=x)
$$
There should be some independence assumption such that 
$$
P(g_n(X, Z) = 1 ,Y=0| X=x)=P(g_n(X, Z) = 1|X=x)P(Y=0| X=x)
$$
A: @Statisfun had the right intuition here, I'll write it out in more detail here:
First we assume independence of $g_n(X, Z)$ and $Y$ given $X=x$. It's not clear to me that this is a valid assumption for a learner, but if I were to justify it I'd say that once $X$ is given the prediction of the classifier no longer depends on Y. I'm not sure this is the correct way to put it.
Then I was making the mistake of writing the probability of error as a sum of probabilities conditioned on both $X=x$ and $Y=y$. This should have been a joint probability instead:
$$
P(g_n(X, Z) \neq Y | X=x) = P(g_n(X, Z) = 1 ,Y=0| X=x) + P(g_n(X, Z) = 0 , Y=1| X=x)
$$
In any case, for brevity we'll write $P(g_n(X, Z) = a ,Y=b| X=x)$ as $P(g_n = a ,Y=b)$. Then we have:
$$
\begin{align}
P(g_n(X, Z) \neq Y | X=x) &= P(g_n = 0 ,Y=1) + P(g_n = 1 ,Y=0) \\
&= P(g_n=0)P(Y=1) + P(g_n=1)P(Y=0) \\
&= P(g_n=0)P(Y=1) + (1 - P(g_n=0))P(Y=0) \\
&= P(g_n=0)\eta(x) + (1 - P(g_n=0))(1-\eta(x)) \\
&= (2\eta(x)-1)P(g_n=0) + 1 - \eta(x) 
\end{align}
$$
For the second line we used the independence assumption, and for the 3rd the fact that $P(g_n=1) = 1-p(g_n=0)$ because it's a binary classification problem.
