Logistic Regression
Despite its name, a classifier: it turns a weighted sum of features into a probability between 0 and 1 using the S-shaped sigmoid curve.
Also logit model
Cox, 1958
It is a yes/no machine that also says how sure it is. Feed it clues about a customer and it says 'leaving: 80% sure'.
Where it fits
+All relationships as a list
Is a kind of / part of
Uses / built on
Trained with
Used by
How it works
Logistic regression starts like linear regression: a weighted sum of features. But a sum can be any number, and we want a probability. So the sum goes through the sigmoid, an S-shaped curve that maps very negative numbers to almost 0, very positive ones to almost 1, and 0 to exactly 0.5.
To make a decision, pick a threshold (often 0.5): above it is “yes”, below is “no”. All the points where the probability is exactly 0.5 form the decision boundary, which is always a straight line (or flat plane).
Training cannot use squared error well here; instead it uses cross-entropy, which punishes confident wrong answers hard. There is no closed-form solution, so the weights are found with gradient descent or a similar optimizer.
The math
Taking logs of the odds shows why it is a linear model:
Everyday use cases
- Case 01
Customer churn
Will this subscriber cancel next month? Yes or no, with a probability the sales team can rank by.
- Case 02
Credit default risk
Banks have used logistic regression for decades because regulators can read the weights.
- Case 03
Click prediction
Will a user click this ad? Fast enough to score billions of ads a day.
Famous examples
Strengths, weaknesses and when to use it
Strengths
- Outputs calibrated-ish probabilities, not just a label.
- Fast, stable and interpretable (weights are log-odds).
Weaknesses
- Linear decision boundary: cannot separate classes that need a curved border without feature engineering.
When to use itFor binary classification where you need probabilities and explainability, and as a baseline for any classifier.
Compare with
Check yourself
- Q01
What kind of task is logistic regression used for?
Show answer
B: Classification
- Q02
What does the sigmoid function do?
Show answer
A: Squashes any number into the range 0 to 1