Decision Boundaries
Decision Boundaries — A decision boundary is the surface a classifier draws to separate classes. Different models draw very different boundaries on the same data: logistic regression a straight line, kNN jagged islands, a tree axis-aligned boxes, an SVM a max-margin street.
Paint a spiral or two moons, then watch four models try to separate it at once — the linear model fails while kNN and the tree contort to fit. The tradeoffs, obvious in a single glance.
Training error at this capacity (click to spotlight a panel)
Compare controls
The idea in plain words
Every classifier draws a different kind of line. Put four on the same data and the tradeoffs are obvious at a glance: logistic regression and SVM draw straight boundaries, kNN draws jagged islands, and a decision tree draws axis-aligned boxes.
On blobs they all look fine. Switch to a spiral or concentric circles and the linear models fail completely while the flexible ones contort to fit — the whole point of having more than one model.
Now, the math
Each model defines its decision region by a different rule:
- a linear score — a straight boundary.
- neighborhood size for kNN — small k means jagged regions.
▸ Show the derivation
Linear models can only separate classes a hyperplane can split; a spiral needs a curved boundary they cannot express. kNN and trees are non-parametric — they carve arbitrarily complex regions, at the cost of overfitting on sparse or noisy data.
Trace it by hand
One query point (2, 3), two models trained on the same five labeled points: a linear classifier with w = (1, -1), b = 0.5, and a 3-nearest-neighbor vote over (1,3) and (2,4) and (3,3) of class 1, plus (4,1) and (5,2) of class 0. Distances rounded to 3 decimal places.
Model 1: the linear rule
Model 2: measure the kNN distances
Model 2: take the majority
The two models disagree
The query sits on the class-0 side of the straight line but inside a local pocket of class-1 points that the line cannot bend around.
What just happened: Score minus 0.5 says class 0; three unanimous neighbors at distance 1.0 say class 1. Decision boundaries differ because each model answers a different question — global line position versus local neighborhood — and the disagreement zone is exactly where model choice matters.
Now Break It
Try this: The spiral breaks the linear model; a sparse dataset makes kNN jagged.
Control: Preset shape picker (spiral / XOR)
What happens: The linear model can’t separate a spiral — only the non-linear models bend to fit.
Where decision boundaries is used
A decision boundary is the surface where a classifier switches from predicting one class to another, and visualizing it is one of the fastest ways to understand how an algorithm behaves. Comparing several classifiers on the same dataset reveals their inductive biases at a glance: logistic regression carves the plane with a straight line, a decision tree produces axis-aligned rectangular regions, k-nearest neighbors traces a jagged boundary that hugs the data, and a kernelized support vector machine bends smoothly around clusters. Practitioners use these side-by-side plots when teaching, when debugging a model that misbehaves near class edges, and when choosing an algorithm whose shape matches the geometry of the problem. Seeing the boundary also exposes overfitting, which shows up as islands wrapped tightly around individual points.
The most common misconception is that a more complicated boundary is a better boundary. A wiggly frontier that perfectly separates the training points often reflects noise rather than signal, and it usually generalizes worse than a smoother one. Another pitfall is forgetting that a boundary lives in the full feature space, not just the two dimensions you happen to plot; a model can look confused in a 2D projection while separating the classes cleanly in higher dimensions. People also assume every classifier draws one connected boundary, but methods like k-nearest neighbors and decision trees can create several disconnected regions for the same class. Finally, the visual boundary is only as trustworthy as the data density around it, since regions with no training examples are essentially guesses.
Frequently asked questions
What exactly is a decision boundary?
Why do different classifiers produce such different shapes?
Does a smoother boundary always generalize better?
Can a boundary be non-linear even for a linear model?
Why should I visualize boundaries in only two dimensions?
Written & reviewed by the ML Visualization team · Last updated .