Lesson 4.1 · 7 min read · about 50 min to master at a very slow pace
Regression versus Classification
When the outcome is a category, we model the probability of each class. Why ordinary linear regression is a poor fit for yes/no outcomes, and why logistic "regression" is a classifier.
Categories, not quantities
Classification predicts a category: spam or not, diabetic or not, which digit. For two classes we code , where 1 is the class of interest ("positive"). The natural target is the probability of class 1:
A class prediction then comes from comparing that probability with a threshold (lesson 4.9).
Why not just use linear regression?
- Impossible predictions: a line goes below 0 and above 1, which can't be probabilities.
- Broken assumptions: when is only ever 0 or 1, the noise can't be "constant variance, roughly normal".
- Fake ordering: with more than two unordered classes (red, green, blue), coding them 1, 2, 3 imposes a meaningless order and spacing.
Why is it called logistic regression?
Because it is a regression, of the log-odds on the predictors: (4.3). It outputs a continuous probability. It becomes a classifier once you add a decision rule like "predict 1 if ". The name describes the model; the use is classification.
| Linear regression | Logistic regression | |
|---|---|---|
| Outcome | A number | A class (via a probability) |
| Models | directly | Log-odds of |
| Output range | ||
| Fitted by | Least squares (closed form) | Maximum likelihood (numerical) |
| Evaluated by | RMSE, MAE, | Confusion matrix, sensitivity, specificity, AUC, log loss |
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passWhy is logistic regression used for classification when it's called regression?
The model itself is a regression: it fits a linear function of the predictors to the log-odds of the outcome and outputs a probability between 0 and 1. Classification happens in an extra step, when you turn that probability into a class with a threshold (e.g. "predict 1 if "). So: regression for the probability, classification for the decision.
Cheatsheet
Linear vs logistic regression
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.