Classification · Part 5
A straight line cannot separate every class pattern. Map the inputs to a new feature space, then use the kernel trick to compute the inner products needed by an SVM.
Part 4 learned a wide linear margin. Now one class surrounds the other. We extend the model by changing the geometry of the feature space.
Map the predictors into a higher-dimensional space and fit a linear SVM there.
When the mapped vectors become too large, compute their inner products directly.
Inspect the inner cluster and outer ring. The outside class surrounds the inside class.
A line cannot put the center on one side and the whole ring on the other. The two points on opposite sides of the ring are joined by a segment that passes through the center.
To separate the center from the ring, map each observation to a cup-shaped surface. Keep its two coordinates and add a third for height.
The center stays at height zero. A ring point gets a positive height. The farther a point lies from the center, the higher it lands on the surface.
A gold diamond marks the selected point. Drag to rotate, or toggle the plane to see the gap between the two height ranges.
The inner points sit below the plane and the outer points sit above it. In the original two-dimensional view, the points at the plane’s height trace a circle.
All blue points are below the cut. All orange points are above it.
The height ranges overlap. No single height cut separates these classes.
We choose the weights and bias that give the widest margin. Minimizing the squared weight norm does this while the constraints keep every training point on or beyond its own margin edge.
The objective stays the same. In the margin constraint, replace xᵢⱼ with ψⱼ(xᵢ).
In the mapped space, . The +1 counts the bias w₀. The feature map itself has m inputs and d outputs. If we fold the bias into the sum, it multiplies the fixed coordinate .
Watch on YouTubeSuppose we only need the dot product of two mapped points. Try this quadratic map, which uses the two squares and their scaled product.
A real dataset may need a much larger feature space. Consider a full degree-10 polynomial map for observations with 100 features. Powers and products quickly make the mapped vector too large to build.
Watch on YouTubeGive each training point one nonnegative parameter, called a Lagrange multiplier. Its value weights that point’s margin constraint.
In the dual problem, we solve for first. The optimal multipliers let us recover the weights and the bias that solve the original SVM problem, called the primal.
The margin rule is . A point that falls short has a negative value inside the parentheses. Subtracting then raises the Lagrangian when .
Use one multiplier per training point to bring the margin constraints into the objective.
Here is the score of training point i.
The weight term favors a wider margin. The sum adds a cost when a point falls short of its margin edge and its multiplier is positive.
Both formulations give the same widest separating strip for this hard-margin SVM. They search using different variables.
Choose how the line tilts and where it sits. Find the widest margin while keeping every point on the correct side of its margin edge.
Give each training point a multiplier. The weighted, signed points add up to the normal. Points with multiplier zero contribute nothing. Use the margin points to locate the line.
Differentiate ℒ with respect to the weights and the bias.
Set both derivatives to zero to obtain the weight vector and the balance condition.
3. Expand the squared norm. Take the inner product of the weighted sum with itself. This gives one term per pair of mapped points. Maximize the result over the allowed multipliers.
Follow three points with the identity feature map, from their original coordinates to the maximum-margin separator.
Lifting the points made it possible to separate the ring from its center. To use that geometry, the dual needs the dot product of each pair of lifted points.
For the feature map from the ring example, compute each term using the two original coordinates of each point.
Reuse the ring example’s feature map. Keep both coordinates and add the height.
For a point with m original features, the quadratic map includes every squared feature and every scaled product of two distinct features.
Build coordinates per point, then take the dot product of the expanded vectors.
Take the dot product of the original inputs and square it. That gives the same result in 2m operations per pair, using the original m coordinates.
The two √2 factors give 2 for every distinct feature pair. Grouping those terms gives the square of the original dot product.
A linear separator in the mapped space can describe a nonlinear boundary in the original inputs.
Use one multiplier per training observation. The data appear through mapped inner products.
Compute each mapped inner product directly from the original inputs.
Read chapters 4 and 7 for linear discriminants, perceptron learning, and support vector machines.
Lecture 15 · Classification · Part 5