Lesson 6.4 · 7 min read · about 45 min to master at a very slow pace

SVM Fundamentals

A support vector machine is a linear classifier that chooses the separating line with the widest safety margin. The idea, the ±1 label convention, the decision rule, and the link to regularisation.

Not startedJump to quiz

The idea: the widest street

For two classes labelled (note: not 0/1), a linear classifier computes a score and takes its sign:

If the classes can be separated by a line, infinitely many lines work. Which is best?

Many lines separate the training data, but some pass very close to points.
The SVM picks the line in the middle of the widest empty street between the classes.

Why a wide margin?

A line squeezed against the training points could be tipped over by a little noise in new data. A line in the middle of a wide gap tolerates more. A wider margin means a simpler, more robust classifier: this is the link to regularisation.

How SVMs fit into the course

Logistic regressionLinear SVM
Labels
LossCross-entropyHinge loss (6.6)
OutputA probability A score / class only (probabilities need extra calibration)
Which points matterAll pointsOnly support vectors: points on or inside the margin
Regularisation (ridge or LASSO) (acts like ), L2 on
Nonlinear boundariesAdd features by handKernels (6.7)
Needs standardised featuresFor penalties: yesYes

Both are linear classifiers with a boundary . They differ in which line they choose, because they use different losses.

Cheatsheet

Logistic regression vs linear SVM

Labels 0/1 vs ±1 · cross-entropy vs hinge · probability vs score · all points vs support vectors · λ vs C · features vs kernels.

SVM decision rule

; predict . Labels .

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptHow does a linear SVM classify a new point ?
Q2applyWhen the classes can be separated, which line does a hard-margin SVM choose?
Q3conceptWhat does a standard SVM output, compared with logistic regression?
Q4conceptWhich labels does the standard SVM formulation use?
Q5conceptWhich training points affect a linear SVM's boundary?