
Support Vector Machines and Margins
A gentle tour of margins, support vectors and the soft-margin cost C in a two-feature SVM, with a worked example, a counterexample about outliers and scaling, and a classroom activity that makes student reasoning visible.
出典
完全なレッスン要約
Two sets of coloured points lie on opposite sides of a ruler. Slide the ruler slightly and the colours may still remain separate. To choose a line when several would classify the training points correctly, a hard-margin linear support vector machine looks for the widest clear strip between the two classes. The decision line runs along the middle of the strip. Points touching its edges constrain where it can sit. They are support vectors. A distant point can move a little without affecting the fitted line. Moving one of the constraining points can change the solution, though the effect depends on which other points still constrain it.
Real data rarely separates cleanly. The soft-margin version allows some points to sit inside the margin or on the wrong side, paying a penalty. The parameter C sets the price. A large C makes the model work hard to classify every training point correctly, so it may accept a narrower margin or tilt the boundary toward an odd observation. A small C tolerates more violations and puts more emphasis on a wide margin. Neither setting is correct in general. C is a tuning choice, examined with held-out data.
Outlying observations deserve attention. One mislabelled point far across the boundary can pull a high-C line toward it, and the classifier may then misplace ordinary new points. Scaling matters too. If study minutes run to 300 and practice score to 10, the distance calculation is dominated by the larger feature. Using scales fitted to the training data can reduce the influence of arbitrary units. The choice still needs a reason connected to what each measurement means.
Now consider a new point close to the decision boundary. Its predicted label is decided by a small distance, so a modest measurement error or a slightly different fitted line could flip the answer. Inspecting such points, perhaps by checking the raw data or collecting a second measurement, is sensible. The distance to the boundary is a useful signal of uncertainty, though it is not a probability.
Try drawing a line through a second diagram. If the two groups form concentric rings, no straight line separates them, and a linear SVM will fail. Support vector machines are not all linear. Kernel functions let the method learn curved boundaries, so the margin picture above describes the linear case only.
Give pairs a printed grid with about twelve labelled points and a ruler. Ask them to draw the separating line they believe leaves the widest equal gap, then mark which points touch the gap edges. Pairs swap sheets and challenge each other. One partner notes, "we moved the line up because this point was closer." The teacher then adds one far outlier and asks pairs to redraw. Comparing sheets makes the effect of margin and outliers visible.


