Hard-SVM
Hard-SVM is concerned not only with whether a hyperplane separates the training set, but also with how far the closest training point is from that hyperplane.
Try it: Support Vector Machine: Maximum Margin
How hard-SVM picks, among all separating lines, the one whose closest training point is farthest away, which points become support vectors, and how soft-SVM trades margin for violations with λ.
How it works
- Hard-SVM: minimise ‖w‖ subject to y(⟨w,x⟩ + b) ≥ 1 for every point; the margin is 1/‖w‖.
- In 2-D the optimum is fixed by one point of each class (their perpendicular bisector) or by two points of one class and one of the other.
- Check every such candidate against all constraints and keep the feasible one with the largest margin; the points on the margin lines are the support vectors.
- Compare with the Perceptron's separator, which also separates but usually with a smaller margin.
- Soft-SVM: minimise λ‖(w, b)‖² + average hinge loss by SGD (step 1/(2λt)), outputting the average iterate.
Default run (3 steps): Hard-SVM: among all (w, b) with y(⟨w,x⟩ + b) ≥ 1 for every point, find the smallest ‖w‖ — equivalently the separator whose closest point is farthest away (margin 1/‖w‖). … Max margin: w = (0.435, 0.696), b = -1.783, ‖w‖ = 0.82; margin 1/‖w‖ = 1.219 (band width 2.438). Support vectors p_5, p_6, p_7 sit exactly on y(⟨w,x⟩ + b) = 1. Checked 64 candidate sets. The Perceptron's line also separates, but its closest point is only 0.271 away.
Simplified: 2-D, at most 12 points, exact candidate enumeration instead of a general QP solver. The soft-SVM SGD regularises the bias too (x is extended with a constant 1) and runs a fixed number of seeded steps.
Loading the simulation…
Why Separation Needs Room
A hyperplane can separate a training set without telling us how much space lies between the training points and the boundary. That space matters. If the instances move slightly, a boundary with very little room may stop separating the classes, while a boundary with more room is more likely to continue separating them. Hard-SVM turns this idea of room into the margin.
Hard-SVM is concerned not only with whether a hyperplane separates the training set, but also with how far the closest training point is from that hyperplane.
The Closest Point Sets the Margin
The margin of a hyperplane with respect to a training set is the smallest distance from any training point to the hyperplane. The word smallest is essential: the margin is determined by the nearest training point, not by an average distance or by a typical point. If one point lies especially close to the boundary, that point limits the available room.
Selecting the limiting distance
Suppose three training points have distances 4, 1.5, and 3 from a separating hyperplane. Which distance is the margin?
- 1List the distances
The distances are 4, 1.5, and 3.
- 2Find the minimum
The smallest distance is 1.5.
- 3Interpret the result
The point at distance 1.5 is the closest training point, so it determines the margin.
The margin is 1.5 in this generated example.
Why a Larger Margin Helps
A large margin means that even the closest training point is relatively far from the hyperplane. That point therefore has room to move before it reaches the boundary. More generally, if the instances are slightly perturbed, a larger gap makes it more likely that the same hyperplane will continue to separate the training set.
This is a robustness argument, not a guarantee that every possible perturbation preserves separation. The claim is that a larger margin provides more room for slight changes. The closest point is the critical one because it has the least room available.
Margin and True Error
| Idea | What it tells us |
|---|---|
| Training separation | Whether the hyperplane separates the given training examples |
| Margin | The smallest distance from a training point to the hyperplane |
| True error | How the halfspace performs beyond the observed training set |
| Margin-based relationship | The margin provides a quantity in terms of which true error can be bounded |
Separation, margin, and true error are related but are not identical quantities.
The margin does not directly report the exact true error of a halfspace. Instead, true error can be bounded using the margin. The important direction is that increasing the margin is associated with a smaller bound on true error. This relationship does not depend on the Euclidean dimension.
The Hard-SVM Optimization
- 1The parameter pair contains w and b, which describe the hyperplane.
- 2The objective is to minimize ‖w‖₂.
- 3The constraint requires every training example to satisfy the classification requirement.
- 4The optimization chooses the smallest-norm parameters among the pairs that satisfy all of those constraints.
The order matters: constraints first, objective second. Minimizing ‖w‖₂ without requiring the classification constraints would not express the Hard-SVM problem described here.
Why Every Example Matters
The constraint is applied to every training example because a separating hyperplane must classify the entire training set according to the required condition. It is not enough for most examples to be on the correct side. One example that violates its constraint prevents the parameter pair from being an acceptable Hard-SVM solution.
Filtering candidate parameter pairs
Imagine three candidate parameter pairs. The first violates the constraint for training example 2, the second satisfies the constraints for examples 1 and 2 but violates the constraint for example 3, and the third satisfies the constraint for all three.
- 1Check candidate one
Reject it because at least one training example violates the required condition.
- 2Check candidate two
Reject it for the same reason: satisfying some constraints is not enough.
- 3Check candidate three
Keep it as feasible because every listed training example satisfies its constraint.
- 4Apply the objective
Among feasible candidates, the Hard-SVM objective prefers the one with the smaller ‖w‖₂.
The feasible set contains only parameter pairs that satisfy every training-example constraint.
Normalized Output Parameters
After solving the optimization problem, the optimization solution is transformed into the stated normalized output parameters. These parameters are the normalized representation of the separating hyperplane produced by the solution. The important interpretation is that normalization is an output step applied to the solution; it does not replace the requirement that the original solution satisfy every training-example constraint.
When reading a Hard-SVM derivation, separate three stages: identify the feasible parameter pairs, minimize ‖w‖₂ over those pairs, and then report the normalized parameters produced from the optimization solution.
Common Reading Errors
Common mistake Treating the average distance as the margin.
What it looks likeSeveral points are far from the hyperplane, but one point is very close.
Why it failsThe margin is determined by the smallest distance.
Do this insteadLocate the nearest training point and use its distance.
Common mistake Assuming separation alone describes robustness.
What it looks likeA hyperplane separates the observed training examples but leaves almost no room around the closest point.
Why it failsSlight perturbations may change the separation when the closest point has little room.
Do this insteadConsider the margin as the available room around the closest training point.
Common mistake Confusing the margin with exact true error.
What it looks likeConcluding that a particular margin directly equals the classifier's true error.
Why it failsThe margin provides a quantity in terms of which true error can be bounded; it does not directly report exact true error.
Do this insteadSay that a larger margin is associated with a smaller true-error bound.
Common mistake Minimizing ‖w‖₂ without the constraints.
What it looks likeReading the objective but ignoring the requirement for every training example.
Why it failsThe constraints define which parameter pairs are acceptable.
Do this insteadRead the constraint first, then the objective over the feasible pairs.
Common mistake Checking only some training examples.
What it looks likeAccepting a candidate because it satisfies the constraint for most examples.
Why it failsHard-SVM requires the classification constraint for every training example.
Do this insteadReject any candidate that violates even one required training-example constraint.
Check Your Understanding
A separating hyperplane has training-point distances 2.8, 0.9, 1.7, and 4.1. Identify the margin, identify the training point that controls it, and explain why a small perturbation is most relevant for that point. Then describe the two parts of the Hard-SVM optimization: the condition that candidates must satisfy and the quantity minimized among acceptable candidates.
Hints
- The margin uses the smallest distance.
- The limiting point is the one associated with that smallest distance.
- The objective is ‖w‖₂, while the constraint must hold for every training example.
What do you think happens?
Which distance determines the margin when the distances are 2.8, 0.9, 1.7, and 4.1?
Reveal answer
The smallest distance, 0.9.
The margin is defined by the closest training point to the hyperplane.
Key Takeaways
- 1The margin is the smallest distance from a training point to the hyperplane.
- 2The nearest training point, rather than an average point, determines the margin.
- 3A larger margin provides more room for slight perturbations and is associated with a smaller bound on true error.
- 4Hard-SVM minimizes ‖w‖₂ only among parameter pairs satisfying the classification constraint for every training example.
- 5The optimization solution is transformed into normalized output parameters representing the resulting separating hyperplane.
At a glance
- Hard-SVM measures the room between a separating hyperplane and its closest training point.
- The margin is the minimum distance, so the closest point controls robustness.
- A larger margin supports more robust separation under slight perturbations and is associated with a smaller true-error bound.
- The optimization first requires every training example to satisfy its constraint and then minimizes ‖w‖₂ among the feasible parameter pairs.
- The resulting optimization parameters are transformed into normalized output parameters.