SVM Dual

The SVM dual is the Lagrangian dual of the soft-margin SVM problem. It has one multiplier per training point, with labels . In the notation of 4.2. Lagrangian Duality, the margin constraints get multipliers . The constraints get multipliers . The Lagrangian is

where is the slack penalty and are the slacks of the primal. Minimizing over , and and substituting back gives the dual problem:

The data enter only through the inner products . The hard-margin dual drops the upper bound . The dual maximizes a concave quadratic, so it is a convex quadratic program. Strong duality holds, so its optimal value equals the primal optimum.

The optimal multipliers give back the primal solution:

where is any point with . Solvers average over all such points. Prediction needs only the points with :

The KKT conditions tie each multiplier to the position of its point relative to the margin:

  • : . The point is on or outside the margin, and it has no effect on the solution.
  • : and . The point is a free support vector on the margin.
  • : and . The point is a bounded support vector, on the margin, inside it, or misclassified.

The support vectors are the points with . Conversely, forces , and forces . At the optimum . For the hard margin this gives the margin width .

Intuition

Every constrained optimization problem has a dual problem whose variables are its Lagrange multipliers. The primal searches over the weights , one per feature. The dual searches over the multipliers , one per training point. Each is the weight that point receives in . The weight vector is therefore a weighted sum of training points, and points beyond the margin get weight zero. The cap limits the weight of any one point.

The dual has two uses. It shows that the solution depends only on the support vectors. It also uses the data only through inner products . Replacing each inner product by a kernel gives the kernel SVM, with the same variables.

Properties

(Primal or Dual) The dual has one variable per sample and the primal one per feature, so each suits a different data shape.

The dual works with the Gram matrix . Forming it costs time and storing it costs memory. With many features and few samples, such as gene expressions for patients, the dual is the smaller problem. With many samples and few features, linear solvers work on the primal. They can also update the dual one coordinate at a time without storing the Gram matrix. A kernel SVM with the RBF kernel has an infinite-dimensional , so solvers work with the dual.

(Box Constraint Caps Influence) The bound limits how much any single point can change .

In the hard-margin dual the multipliers have no upper bound. A point close to the other class can receive a large and dominate . The soft margin caps every multiplier at , so a gross outlier contributes at most to . Every point inside the margin or misclassified has , however large its slack. This is the dual form of the fact that the hinge loss has slope at most in magnitude. On separable data the soft and hard solutions coincide once . The hard-margin multipliers are then feasible for the soft dual and remain optimal.

(Leave-One-Out Bound) The leave-one-out error of an SVM is at most the fraction of training points that are support vectors.

Remove a point with and retrain. The old solution still satisfies every KKT condition of the smaller problem, so it stays optimal. The removed point has , so the unchanged classifier labels it correctly. Leave-one-out errors can therefore occur only at support vectors (Vapnik 1995):

A model with support vectors among points has a leave-one-out error of at most . Few support vectors thus guarantee a low leave-one-out error without retraining. The bound is loose on noisy data, where many points sit inside the margin.

(Non-Unique Bias) When no multiplier lies strictly between and , the KKT conditions confine only to an interval.

Without a free support vector, the formula has no point to use. Each remaining KKT condition gives a one-sided bound on . Points with need , and points with need . Every in the resulting interval is optimal, and LIBSVM returns its midpoint (Chang and Lin 2011). Take healthy readings at and , faulty readings at and , and . The solution has and . Every gives the same objective , and LIBSVM reports . The weight vector stays unique because is strictly convex.

(Sequential Minimal Optimization) Solvers update two multipliers at a time, because the equality constraint forbids changing one alone.

Changing a single would violate . Sequential minimal optimization (SMO, Platt 1998) picks two multipliers and . It moves them along the line . On that line the dual is a quadratic in one variable. SMO maximizes it in closed form and clips the result to the box . Each step needs only two columns of the Gram matrix, so the full matrix is never stored. LIBSVM picks a pair that badly violates the KKT conditions, using second-order information (Fan, Chen and Lin 2005). It stops when every violation is below a tolerance. SMO is a form of coordinate descent on blocks of two coordinates.

Derivation

Start from the soft-margin primal, a convex quadratic program with affine constraints. In the form of 4.2. Lagrangian Duality, the objective is . The inequality constraints are and . Their multipliers are and , where the duality note writes .

The dual function minimizes over , and . The Lagrangian is a convex quadratic in and linear in and . Setting its partial derivatives to zero gives the stationarity conditions:

If the second or third condition fails, is linear with nonzero slope in or , and . Such multipliers give no useful lower bound, so the dual keeps only multipliers that satisfy both conditions. Since , the requirement becomes . With these conditions the terms in and cancel. Substituting then gives

because . Maximizing over the feasible multipliers is the dual problem. Let have entries . Then with , so is positive semidefinite. The dual is the convex QP of minimizing over the box and the hyperplane .

Strong duality follows from Slater’s condition, which asks for a strictly feasible primal point. For the soft margin, any with large enough slacks makes every constraint strict. For the hard margin on separable data, doubling a feasible gives . The KKT conditions then characterize the optimum. Complementary slackness reads

If , the second condition gives , and primal feasibility gives . If , both conditions force their other factor to zero. Then and . If , the first bracket vanishes and , so . A free support vector has . Multiplying by and using gives .

Examples

(Easy) Two Emails in Closed Form

A spam filter has one spam email at with and one legitimate email at with .

(Medium) Multipliers for Four Sensor Readings

Faulty machines () read and . Healthy machines () read and . The hard-margin solution from 4.4. Support Vector Machines is and .

(Hard) Overlapping Spam Counts

A filter uses one feature, the number of links in an email. Legitimate emails () have and links. Spam emails () have and links. The soft-margin SVM uses .

See Also