The four XOR points (1,1) and (−1,−1) with label +1, and (1,−1) and (−1,1) with label −1, are not linearly separable. Solving the hard-margin SVM dual with the kernel k(x,z)=(1+x⊤z)2, what are the αi, the bias and the decision function?

Supervised learning, Kernel SVM numericals
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can build a kernel matrix, exploit symmetry to solve a small dual, and interpret the resulting decision function.

Key idea

Maximise ∑αi−12α⊤Qα with Qij=yiyjk(xi,xj), subject to α≥0 and ∑αiyi=0. By symmetry all four αi are equal.

Steps

  1. Kernel matrix: k(x,x)=(1+2)2=9. For (1,1) and (−1,−1), x⊤z=−2, so k=(1−2)2=1. For points from different pairs, x⊤z=0, so k=1. Hence K=8I+11⊤.
  2. With y=(+,+,−,−): α⊤Qα=∑ijαiαjyiyjKij=8∑αi2+(∑iαiyi)2. The constraint ∑αiyi=0 kills the second term, leaving 8∑αi2.
  3. By symmetry, set all αi=a. The constraint holds (2a−2a=0). The objective is 4a−12⋅8⋅4a2=4a−16a2.
  4. Differentiate: 4−32a=0, so a=1/8. Dual value =0.5−0.25=0.25, so ∥w∥2=2×0.25=0.5 in feature space.
  5. All four points are support vectors. Find b from y1(∑jαjyjk(xj,x1)+b)=1: the sum is 18(9+1−1−1)=1, so b=0.
  6. Decision function: expand (1+x⊤z)2 and sum with weights αjyj. The terms 1, x1z1, x2z2, x12z12, x22z22 cancel, and only the cross term 2x1x2z1z2 survives. This gives f(x)=18⋅4⋅2 x1x2=x1x2.
  7. So the classifier is the sign of x1x2, which separates XOR perfectly. The separating hyperplane lives in the feature space, where x1x2 is a coordinate.

Common mistakes

How long your answer should be

One page; 7–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: In a screening task, a false negative costs 20 and a false positive costs 1, with no cost for correct decisions. What probability threshold minimises expected cost? A model trained after keeping only 10% of the negatives outputs ps=0.5 for a patient. What is the true probability, and what do we decide?
Next in Supervised learning: A soft-margin SVM uses a different penalty for each class: min⁡12∥w∥2+C+∑yi=+1ξi+C−∑yi=−1ξi with the usual constraints. What changes in the dual and in the KKT conditions? In what direction does the boundary move if C+>C−, and how would you choose C± for an imbalanced dataset?