Classical machine learningML 01
Regression
Regression predicts a number from other numbers. The classic method, least squares, draws the line that makes the squared vertical distances from the points as small as possible. It underlies everything from price estimates and growth charts to clinical risk scores. Click to add points and drag them to move, and watch the line respond. Raise the degree to fit curves, then hold out a test set to see how easily a flexible model fits noise. The data are fictional.
filled: training points · hollow: test points · dashed: residuals (prediction errors) · squares: squared errors, whose total area is what least squares makes as small as possible · λ shrinks the coefficients towards zero
Why squares?
Squaring the errors makes them all positive and punishes large misses more than small ones, and it gives a unique best line that can be computed directly, without trial and error. Adrien-Marie Legendre published the method in 1805 to fit the orbits of comets. The price is sensitivity to outliers: one extreme point carries the square of its distance, so it can tilt the whole line. Try the outlier example, then drag that point around.
Overfitting and the test set
A higher-degree curve can always get at least as close to the training points, so training error never gets worse as the degree rises. What matters is how well the model predicts points it has not seen. With a test set held out, the training error falls as the degree rises while the test error eventually climbs again: the curve has started fitting noise. Ridge regression (Hoerl & Kennard, 1970) adds a penalty λ on the size of the coefficients, trading a little bias for a smoother, more stable curve.
Where the name comes from
Francis Galton first saw the effect in sweet peas in 1877, calling it “reversion”. In 1886 he showed that children of unusually tall parents tend to be less extreme than their parents, and named it “regression towards mediocrity”. Regression to the mean turns up wherever something is measured twice: a team after a record season, a pupil after an unusually good exam, or a patient enrolled in a trial because a reading was unusually high will, on average, do less extremely next time, whether or not anything changed.
References
- Legendre, A.-M. (1805). Nouvelles méthodes pour la détermination des orbites des comètes. Paris. (Appendix: the method of least squares.)
- Galton, F. (1886). Regression towards mediocrity in hereditary stature. Journal of the Anthropological Institute of Great Britain and Ireland, 15, 246–263.
- Hoerl, A. E., & Kennard, R. W. (1970). Ridge regression: biased estimation for nonorthogonal problems. Technometrics, 12(1), 55–67. doi.org/10.1080/00401706.1970.10488634
- Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning (2nd ed.), chapters 3 and 7. Springer. doi.org/10.1007/978-0-387-84858-7 · free online: hastie.su.domains/ElemStatLearn