Linear or logistic regression: a number, or a yes/no
What linear and logistic regression each predict, why logistic outputs a probability through the sigmoid, why the 0.5 threshold is a business choice, and what both models have in common: one page.
Get the free PDF
One page, print-ready, free to share. No signup needed.
Which model do you build first? It depends on the question. If the answer is a number, you want a linear regression. If the answer is a yes or a no, you want a logistic one. This page covers what each predicts, why logistic outputs a probability, the threshold that is a business choice, and the one thing both models share. The print-ready A4 PDF is at the bottom.
Linear
- Predicts a number: price, demand, minutes.
- The output can be any value, from minus to plus.
- The loss is squared error.
Logistic
- Predicts a probability: churn, fraud, click.
- The output is between 0 and 1, through the sigmoid.
- The threshold turns the probability into a yes or a no. 0.5 is a choice, not a law.
Same inputs, two outputs
Both models draw a line through the features. One reads the line as a number, the other pushes it through a sigmoid and reads a probability.
| Linear | Logistic | |
|---|---|---|
| Formula | y = b0 + b1·x1 + b2·x2 | p = sigmoid(b0 + b1·x1 + b2·x2) |
| The line is | the prediction | the log-odds |
| Fit by | least squares | maximum likelihood |
| You read | "price is about 240" | "72% chance of churn" |
Remember
- Both are linear in the inputs. The difference is the output.
- With imbalanced classes, move the threshold and check recall.
Imbalance matters because a model on rare events, such as fraud, can look accurate by saying no every time. Recall tells you how many of the real cases you caught.
The trap: the threshold is a decision
A logistic model gives a probability. The yes/no comes from a threshold you choose.
| Threshold | Flags more | Use when |
|---|---|---|
| 0.5 | balanced | classes are balanced, errors cost the same |
| 0.2 | yes | missing a case is expensive: fraud, churn |
| 0.8 | no | a false alarm is expensive: a manual review |
A lower threshold flags more cases as yes, so you catch more real ones and accept more false alarms. A higher threshold does the opposite. There is no neutral setting: each value is a trade between the two kinds of error.
Interview phrasing worth memorizing: logistic regression gives me a probability; I pick the threshold with the business, from the cost of each kind of error.
Frequently asked questions
What is the difference between linear and logistic regression?
Why does logistic regression use a sigmoid?
Is 0.5 always the right threshold for logistic regression?
What do linear and logistic regression have in common?
Get the free PDF
One page, print-ready, free to share. No signup needed.