XOR separation by a product feature (source code)

= XOR separation by a product feature
{c}
{title2=$y=-x_1x_2$}

Give the four corners of the square the <exclusive or> labels: $+1$ when the input signs differ and $-1$ when they agree. In the following order,
$$
p_1=(1,1),\quad p_2=(1,-1),\quad p_3=(-1,1),\quad p_4=(-1,-1),\qquad y=(-1,1,1,-1)^T.
$$
No <affine function> $g(x)=a_1x_1+a_2x_2+b$ has the required strictly positive scores at $p_2,p_3$ and strictly negative scores at $p_1,p_4$: both pairs have midpoint zero, so $g(p_2)+g(p_3)=2b=g(p_1)+g(p_4)$ would have to be both positive and negative. This also rules out perfect classification by a single threshold with a consistent tie rule.

Under the <polynomial kernel>'s <quadratic feature map>, the two classes become two distinct <vectors>:
$$
\phi(p_1)=\phi(p_4)=(1,\sqrt2,1)^T,\qquad \phi(p_2)=\phi(p_3)=(1,-\sqrt2,1)^T.
$$
The <hyperplane> $\phi_2=0$ separates them. With $w=(0,-1/\sqrt2,0)^T$ and $b=0$, the score and <classifier> are
$$
f(x)=w^T\phi(x)=-x_1x_2,\qquad h(x)=\operatorname{sgn}f(x).
$$
All four signed scores $y_i f(p_i)$ equal one. In the input plane the boundary is $x_1x_2=0$, the union of the coordinate axes; in the derived coordinates it is a single <hyperplane>. The <feature map> identifies opposite corners, which is harmless for these labels because opposite corners belong to the same class. A fixed <feature map> would not separate labels that disagree at identical mapped <vectors>.

\Image[/kernel-quadratic-xor-feature-separation.png]
{title=XOR labels in the input square and the quadratic feature slice}
{description=The dashed diagonals join equal-label input pairs and share their midpoint, obstructing affine separation. In the feature panel all mapped points have third coordinate one; the two coincident pairs are separated by the horizontal hyperplane at second coordinate zero.}