Logistic Regression
Bend a straight line into an S-curve to predict probabilities for yes-or-no categories.
Linear regression breaks when the target is a category. You can encode 'No' as 0 and 'Yes' as 1, but a straight line doesn't stop — it will predict 120% probabilities for high inputs and negative probabilities for low ones.
The S-Curve
We need a function that maps any number to the range between 0 and 1. The sigmoid function takes a linear score and squashes it. Huge positive numbers become 99.9%, huge negatives become 0.1%.
Sliding to Fit
The model still learns an intercept and a slope, just like linear regression. But instead of drawing the line directly, those numbers slide the S-curve left or right, and stretch or compress its steepness, until the high probabilities land on the 'Yes' points.
The Decision Boundary
Every point on the curve is a probability. The exact spot where the curve crosses 50% is the threshold. Drop a line straight down from there: everything to the right is predicted as 'Yes', everything to the left as 'No'.
Straight Lines Only
Because the underlying math is a straight line, the resulting decision boundary is always a flat hyperplane. If your data requires a circular or winding boundary to separate the classes, logistic regression cannot bend to fit it.
The Quick Version
- Straight lines make terrible probabilities.
- A sigmoid squashes lines into the 0–1 range.
- The model shifts the curve to fit the points.
- The 50% mark is the decision boundary.
- The boundary itself is always a straight line.