Solution (source code)

= Solution

Let $w=N(U)/N(R)$, so $1-w=N(V)/N(R)$. Since class counts add,
$$
\widehat p(R)=w\widehat p(U)+(1-w)\widehat p(V).
$$
The function $g(p)=p(1-p)$ is <concave function> on $[0,1]$. <Jensen inequality> therefore gives
$$
G(R)=g(\widehat p(R))
\geq wg(\widehat p(U))+(1-w)g(\widehat p(V)),
$$
which is precisely $Q\leq0$. Thus an axis-aligned split cannot increase the weighted empirical Gini impurity.