Skip to content
AI360Xpert
Visual Explainers
Visual explainer

Logistic Regression

Bend a straight line into an S-curve to predict probabilities for yes-or-no categories.

When predicting categories like yes or no, a straight line shoots past 100% and drops below 0%.
When predicting categories like yes or no, a straight line shoots past 100% and drops below 0%.

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

The sigmoid curve bends the straight line so it approaches but never crosses 0 and 1.
The sigmoid curve bends the straight line so it approaches but never crosses 0 and 1.

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 underlying linear model shifts and stretches the curve to fit the data.
The underlying linear model shifts and stretches the curve to fit the data.

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

The point where the curve crosses 50% is the decision boundary.
The point where the curve crosses 50% is 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

Logistic regression can only draw straight-line boundaries. If the classes wrap around each other, it fails.
Logistic regression can only draw straight-line boundaries. If the classes wrap around each other, it fails.

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.