difficulty 3/5
Logistic regression
A linear model for classification — it feeds a weighted sum through a sigmoid to produce a calibrated probability rather than a raw score, despite the "regression" in its name.
Intuition
You want a probability, and linear regression cannot give you one. Fit a straight line to a 0/1 outcome and it will happily predict 1.4 or −0.2, which are not probabilities and cannot be made into them by rounding.
Logistic regression keeps the weighted sum and passes it through a sigmoid, which squashes any real number into (0, 1). Large positive sums approach 1, large negative sums approach 0, and zero maps to exactly 0.5. The output is a genuine probability you can threshold, rank, or feed into an expected-cost calculation [2, §5.7.1].
Formal definition
How it works
Where it's used
Why & when
Worked example
Pitfalls
Check yourself
3 questions
The questions on this page come with access. They are graded on the server, so the answers stay there until you have given yours.
On the cheat sheet: Linear models →
Sources
- scikit-learn — sklearn.linear_model.LogisticRegressiondocs · retrieved 2026-08-31https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html
- Deep Learning (2016)book · retrieved 2026-10-07https://www.deeplearningbook.org/