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.

Not startedJump to quiz

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?

00.510246810hours studiedpassed (1) or not (0)
Linear regression: goes below 0 and above 1Logistic regression: stays between 0 and 1
Fitting a straight line to 0/1 outcomes produces "probabilities" outside [0, 1] (shaded). The S-shaped logistic curve doesn't.
  • 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 regressionLogistic regression
OutcomeA numberA class (via a probability)
Models directlyLog-odds of
Output range
Fitted byLeast squares (closed form)Maximum likelihood (numerical)
Evaluated byRMSE, 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

Linear: number, models , OLS, RMSE/. Logistic: class via , linear in log-odds, MLE, confusion matrix/AUC.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptWhy is ordinary linear regression a poor choice for a yes/no outcome coded 0/1?
Q2diagnoseTo predict which of three unordered product categories a customer buys, a team codes them 1, 2, 3 and fits linear regression. What's the core problem?
Q3conceptLogistic regression is a linear model of what?
Q4applyA logistic regression outputs for a customer. How does that become a class prediction?
Q5applyYou built a churn classifier. Which set of measures should you report?