Linear SVM vs Logistic Regression
Both draw a straight decision boundary between two classes, but a linear SVM asks only 'which side, with how much margin?' while logistic regression asks 'what's the probability?' — a difference in loss function that changes which points the model actually pays attention to.
Prerequisites: Logistic Regression, Soft-Margin SVMs and the C Parameter
Given two classes of points that can roughly be separated by a straight line, both a linear support vector machine (SVM) and logistic regression will draw very similar-looking lines. But they get there by optimizing genuinely different things, and that difference shows up clearly once points sit far from the boundary or near it. Logistic regression asks every single point, "given where the boundary is, how probable is your class?" and adjusts the boundary to make all of those probability judgments as accurate as possible. The linear SVM asks a narrower question: "are you on the correct side, with enough margin?" and mostly ignores points that already comfortably satisfy that.
The analogy: a strict bouncer versus a probability-quoting analyst
A linear SVM behaves like a bouncer enforcing a velvet rope: anyone safely inside the rope's buffer zone gets zero further attention, but anyone crossing the line or standing too close to it gets pushed back — the bouncer's whole effort concentrates on the borderline cases (the support vectors), and people standing comfortably in the middle of the room could double their distance from the rope and nothing about the bouncer's decision would change. Logistic regression is more like an analyst who assigns everyone a probability of belonging to one side or the other: someone deep in the middle of the room still gets an assigned probability (close to 100%), and if that person moved slightly, the analyst's overall fitted probabilities would shift too, at least a little — every point continues to matter, not just the borderline ones.
The loss functions, side by side
Let be the "signed margin" for a point with true label . Logistic regression minimizes the log loss:
The linear SVM minimizes the hinge loss:
Plain English: log loss is smooth and never truly reaches zero — even a point correctly classified with huge margin () still contributes a tiny, nonzero penalty and a tiny, nonzero gradient, so it keeps nudging the boundary, however slightly. Hinge loss hits exactly zero once — a point correctly classified with margin at least 1 contributes nothing at all, zero gradient, and has no further influence on the fitted boundary. That's the mathematical source of "SVM only cares about the borderline points."
Worked example 1: comparing losses for three points
Three points with margins (misclassified), (correct but close), (correct and far). Hinge loss: ; ; — the far point contributes exactly zero. Log loss: ; ; — nonzero for every point, however small for the far one. Only the SVM's loss actually zeroes out; logistic regression's asymptotically approaches zero but never gets there, so it keeps a faint pull from every point in the dataset.
Worked example 2: how an outlier moves each boundary
Suppose fitting on 20 well-separated points gives both models nearly the same boundary. Add one extreme outlier far on the correct side, at : the SVM's hinge loss is exactly, so this point contributes literally nothing to the optimization and the boundary is unchanged. Logistic regression's log loss is — vanishingly small but not zero, contributing a negligible but technically nonzero gradient that in principle still nudges the fit, in a way the SVM's identical-looking point would not.
Add points far from the boundary on the correct side and watch whether the boundary itself moves — under a hinge-loss (SVM-style) model those points would leave the boundary completely untouched, while a smooth log-loss model keeps a faint, ever-shrinking sensitivity to them.
What this means in practice
Choose the linear SVM when you want a decision boundary that's robust to well-separated, non-borderline points and don't need calibrated probabilities — just a clean side/no-side call, useful for a hard go/no-go filter. Choose logistic regression when you need actual probability estimates (position sizing proportional to confidence, or feeding a probability into a downstream expected-value calculation) since its output is a genuine (if sometimes miscalibrated) probability, whereas an SVM's output is just a raw, unnormalized distance from the boundary that requires extra calibration (e.g. Platt scaling) to turn into anything probability-like.
Linear SVM (hinge loss) and logistic regression (log loss) both fit a linear decision boundary, but hinge loss hits exactly zero for any point correctly classified beyond the margin — so only borderline "support vector" points influence the SVM's boundary — while log loss stays (very slightly) nonzero everywhere, so logistic regression keeps every point's influence, however small.
It's a common mistake to treat an SVM's decision-function output — the signed distance — as if it were a probability the way logistic regression's sigmoid output is. It isn't calibrated to be one at all; two SVMs trained on different datasets can produce wildly different raw score scales for what is genuinely the same confidence level. If you need probabilities from an SVM, you need an explicit calibration step (Platt scaling: fitting a logistic regression on top of the SVM's scores) — never just min-max normalize the raw scores and call them probabilities.
Related concepts
Practice in interviews
Further reading
- Hastie, Tibshirani & Friedman, The Elements of Statistical Learning, Ch. 12 (2009)