difficulty 4/5
Generalized linear models
One framework that covers linear, logistic and Poisson regression at once — a linear predictor, a link function connecting it to the response, and a distribution for the noise.
Intuition
Linear regression assumes the response is roughly normal and unbounded. That breaks constantly. Counts cannot be negative. Probabilities live in [0, 1]. Waiting times are skewed and strictly positive. Fitting a straight line to any of them produces predictions that are not merely inaccurate but impossible: a straight line fitted to zeros and ones can predict "y=1.1 or y=−0.1, and those are not valid probabilities" [3, §11.6].
GLMs keep the useful part — a linear combination of the features — and make two things adjustable around it: a link function mapping the linear predictor to the valid range of the response, and a distribution family describing how the response varies around its mean [1, technical documentation].
Do that, and linear, logistic and Poisson regression stop being three models and become three settings of one [3, §11.6].
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.
Sources
- statsmodels — Generalized Linear Modelsdocs · retrieved 2026-08-31https://www.statsmodels.org/stable/glm.html
- scikit-learn User Guide — Linear Modelsdocs · retrieved 2026-10-04https://scikit-learn.org/stable/modules/linear_model.html
- Think Stats — Ch. 11, Regression, 2nd ed.book · retrieved 2026-10-06https://greenteapress.com/thinkstats2/html/thinkstats2012.html