Visual explainer
Support Vector Machines
Draw the widest street between two classes, anchor the boundary on border support vectors, and forgive slack crossings when data overlaps.
A support vector machine chooses a separating boundary by balancing a wide margin against penalties for violating class margins. For separable data, the hard-margin version chooses the widest empty corridor. Zero training error alone does not choose a unique separator or guarantee accurate unseen predictions.
Our synthetic two-feature data has negative circles N1=(−2,−1), N2=(−2,1), N3=(−3,0), and positive squares P=(2,0), P2=(3,1), P3=(3,−1). Both spatial axes use 50 SVG units per coordinate unit. The vertical lines at x=−1.5, 0 and 1.5 all separate these six samples; their nearest-sample clearances are 0.5, 2 and 0.5 respectively. The bottom zero labels the central line's coordinate; the upper −1 and +1 labels identify classes.
Which Points Set the Margin?
The center boundary is x=0; dashed gutters are x=−2 and x=2. Double outlines identify N1, N2 and P, the three support vectors in this fixture. The segment joining N1 and N2 contains (−2,0). P=(2,0) is four units away. These are the closest points of the two class convex hulls, so a separating corridor cannot be wider than four; the depicted vertical corridor attains that width.
A general SVM need not have three support vectors. With soft margins, supports may also lie inside a margin or be misclassified. Samples with zero dual coefficients contribute nothing to a fixed fitted kernel prediction; moving them far enough to create a new active constraint can change a refitted model.
Measure Perpendicular Width
Write a linear decision score as . In canonical hard-margin scaling, the gutters satisfy . Here and , giving gutters at x=±2. The normal arrow points perpendicular to the boundary; the right-angle mark makes this explicit. Its short length uses the separate weight-vector units, while the lower bracket measures data-space width.
Each half-margin is coordinate units, and the full width is . At 50 SVG units per data unit, the caliper is exactly 200 units long. The reciprocal relationship assumes the canonical gutter normalization; rescaling w and b together preserves the decision boundary but changes raw scores.
Map a Nonlinear Pattern
Switch to a one-dimensional example: a negative circle at x=0 and positive squares at x=−2 and 2. No single input threshold places both squares on one side and the circle on the other. Map each input to . Their mapped coordinates become (0,0), (−2,4), and (2,4), separable by the horizontal line z=2. In the original input, that cut means , with two thresholds at ±√2.
The left ruler uses 30 SVG units per input unit; the mapped plot uses 35 per horizontal unit and 40 per vertical z unit. The arrow denotes a mapping, not a measured displacement. This is an explicit illustrative feature map. Its kernel is , the dot product of those mapped features. A kernel implementation can evaluate these inner products without storing the mapped coordinates; a useful feature map still needs to fit the task.
What Does Slack Measure?
Return to the original six samples and add negative circle O=(1,1). Keep the earlier candidate w=(0.5,0), b=0 fixed for this measurement. Its score at O is 0.5, on the positive side. For label y=−1, its signed margin is , and its minimum slack is .
Slack is dimensionless. The bracket shows the corresponding data-space penetration from the negative gutter x=−2 to O's x=1: units, or 150 SVG units. This is not an optimizer's path and does not claim a fitted margin widened by a measured percentage. A point with can be correctly classified yet inside its class margin; puts it on the wrong side.
How Does C Matter?
The official SVC formulation minimizes subject to the class-margin constraints. Compare two feasible candidates on all seven samples, including O. A is the previous w=(0.5,0), b=0: its regularization term is 0.125 and its total minimum slack is 1.5. B uses w=(2,0), b=−3: its boundary is x=1.5, its gutters are x=1 and 2, its regularization term is 2, and every sample has zero slack.
At C=1, A costs , less than B's 2. At C=2, A costs , more than B's 2. Both panels use 100 SVG units per objective unit: dashed sections show regularization cost and solid mint sections show weighted slack cost. Their preference crosses at C=1.25. These are two candidates, not claims that either is the optimized soft-margin fit for the displayed C. Smaller C reduces the penalty for violations; it does not automatically make a model robust or suitable for noisy data. Validate C with the chosen representation and kernel.
Count Pairwise Kernel Entries
If a kernel method materializes every training-pair score, the table has n rows and n columns. The left 2×2 grid contains 4 entries; the right 4×4 grid contains 16. Equal 40-unit cells make the right grid's area four times larger. This counts storage elements, not measured training time.
Solvers can cache or calculate entries as needed, so this picture does not imply every SVM allocates a complete dense table. Runtime depends on the solver, kernel, data and tolerances. Feature scaling also changes margin geometry; use a justified representation and learn fitted preprocessing on training data.
Classify a New Point
Restore the original six-point hard-margin model, without O. For a new q=(1,0), , so the predicted label is +1, shown by the output square. The triangle marks the query on a score ruler; the large square is an outcome symbol, not another observation. Scores −1, 0 and +1 align with the earlier gutters and boundary at 100 SVG units per score unit.
The signed data-space distance to the boundary is . A raw score of 0.5 is not a 50% probability. Scores and distances also have different units.
Predict From Supports
The same query can be evaluated with the linear kernel and . Use coefficients αN1=αN2=1/16 and αP=1/8; the other three coefficients are zero. Their signed sum is , and their weighted input sum reconstructs w=(0.5,0).
For q=(1,0), the contributions are from each negative support and from P. Their sum plus b=0 is 0.5. The three contribution bars and partitioned total share a scale of 400 SVG units per score unit. These nonnegative coefficients, active constraints and reconstructed weights certify the hard-margin solution in this fixture. Kernel prediction retains the same support-weighted structure even when an explicit linear w in the input space is unavailable.
Where It Breaks
Two observations now share exactly the same input x=(1,0) but have opposite labels. The circle and square intentionally share a center; the two leaders identify the contradictory observations rather than two nearby coordinates. Any deterministic score assigns both the same output. The displayed +1 output therefore misclassifies the negative observation.
For any common score f, their total hinge slack is . A kernel still maps identical inputs to identical features; changing C cannot make both predictions correct. Soft margins allow this conflict to be represented in the objective, but cannot recover information absent from the inputs. Investigate labeling errors or missing features, and evaluate against the ambiguity the task actually contains.
The Quick Version
- Several boundaries can separate the same training data.
- Support vectors constrain the fitted margin.
- Canonical margin width is measured perpendicular to the boundary.
- A suitable feature map can separate a nonlinear pattern.
- Slack measures class-margin violations, including some correctly classified samples.
- C changes the cost of violations relative to weight size.
- A complete pairwise kernel table has quadratic entry count.
- A decision score's sign predicts a class, not a probability.
- Nonzero support coefficients determine the kernel prediction.
- Identical inputs with opposite labels force an irreducible classification conflict.