The Decision Boundary
From probability to prediction
Logistic regression outputs a probability . To make a concrete class prediction, a threshold is applied:
The default threshold is , which corresponds to predicting whichever class is more probable. The decision boundary is the set of points where exactly — the dividing line between predicted class 0 and predicted class 1.
The linear decision boundary
With threshold , the decision boundary occurs where , which means , which means . So the boundary is defined by:
This is a linear equation — it defines a straight line (in 2D), a plane (in 3D), or a hyperplane (in higher dimensions). This is why logistic regression is called a linear classifier: it separates classes with a flat boundary.
Two-feature example
Suppose a model with two features (study hours) and (sleep hours) predicts whether a student passes an exam:
The decision boundary is where:
Points above this line (more sleep relative to study hours) are predicted to pass (); points below are predicted to fail ().
Interpreting the coefficients
Each coefficient has a direct interpretation in terms of log-odds:
- Increasing by one unit multiplies the odds of the positive class by , holding all other features fixed.
For the example above, : one additional study hour multiplies the odds of passing by — more than doubling the odds, all else equal.
This log-odds interpretation makes logistic regression highly interpretable, especially compared to black-box models.
Adjusting the threshold
The 0.5 threshold is not always optimal. The right threshold depends on the costs of different errors:
- A false negative (predicting 0 when truth is 1): e.g. missing a disease.
- A false positive (predicting 1 when truth is 0): e.g. unnecessary treatment.
If false negatives are very costly (medical diagnosis), lower the threshold to predict positive more readily. If false positives are costly (spam filtering where legitimate emails matter), raise the threshold.
Changing the threshold moves the decision boundary but does not retrain the model — the underlying probabilities stay the same.
Non-linear decision boundaries
Logistic regression itself is always linear. However, you can create non-linear boundaries by adding engineered features such as:
- Polynomial features: , ,
- Interaction terms: products of pairs of features
- Transformations: ,
For example, adding and allows the decision boundary to be an ellipse. The model remains logistic regression — only the feature set has changed.
Linear separability
If a straight hyperplane can perfectly separate the two classes, the data is linearly separable. In this case, gradient descent will try to push the boundary further and further from all training points, driving coefficients toward — a phenomenon called perfect separation or the complete separation problem, discussed further in the Assumptions lesson.