Maimum Margin Classifier uses hyper planes to find a separable boundary between linearly separable data points.
Suppose we have a set of data points with \(p\) predictors and they belong to two classes given by \(y_{i} = \{-1 , 1\}\). Suppose the points are perfectly separable through a hyperplane. Then the following hold
Thus classification can be made into the positive or negative class simply based on the sign of the quantity \(\beta^{T}x\). The further a point is, the more confident we will be in the classification.
Note that there can be infinite such hyperplanes that perfectly separate the data, and each can be obtained by slightly perturbing the given plane. Define margin as the minimum perpendicular distance from all training observations to this plane. The maximum margin classifier will be the one for which this margin is maximum.
The Maximal Margin Classifier with the Support Vectors. Dotted lines represent the margin.
Note that the location of the maximal margin is determined only by the points closest to the boundary. If a point farther away would slightly move, the boundary would still be the same. Whereas if the point closer to the boundary would shift, the boundary itself would change as can be seen in the figure above. These set of observations are know as support vectors. And by symmetry, the perpendicular distances of these closest points from the plane are same.
Finding the boundary is same as solving for the following optimization problem (\(M\) is the margin)
\[
\begin{aligned}
&\maximize_{\beta_{0}, \beta} M\newline
&\text{subject to} \quad \sum_{i=1}^{p} \beta_{i}^{2} = 1,\newline
&\text{and} \quad y_{i}(\beta_{0} + \beta^{T}x_{i}) \geq M \quad \forall \quad i = 1, 2, \ldots, N
\end{aligned}
\]
The constraint \(\sum_{i=1}^{p} \beta_{i}^{2} = 1\) gives rise to the unique property that \(\beta_{0} + \beta^{T}x\) is the perpendicular distance of the point \(x\) from the hyperplane, making the last constraint equation valid.
By using the perpendicular distance using the equation from appendix, we can replace the constraint on the norm and rewrite as
\[
\begin{aligned}
&\maximize_{\beta_{0}, \beta} M\newline
&\text{subject to} \quad y_{i}(\beta_{0} + \beta^{T}x_{i}) \geq M \lVert \beta \rVert \quad \forall \quad i = 1, 2, \ldots, N
\end{aligned}
\]
Note that the last equation remains same when we multiply by a positive constant. Hence, we can choose \(\lVert \beta \rVert = 1/M\) for simplicity and the maximization problem becomes a minimization one (a factor of \(1/2\) is introduced to simplify the derivative of the square term)
which is a quadratic optimization problem with linear constraints, and is solvable through linear optimization softwares. Maximizing the the dual will give us the lower bound of the optimal solution.
KKT conditions also need to be satisfied for the optimal solution, which gives
which is expected based on the definition of the problem as only the points on margin decide the separating hyperplane. The predictions for new data points are simply made on the basis of the sign of \(\beta_{0}^{\*} + \beta^{\*T}x\)