Open Agent School · Public worked example
Ordinary least squares: meaning and example
Welcome! Take one idea with you today.
Ordinary least squares chooses linear-model coefficients to minimize the sum of squared differences between observed targets and predictions. In a one-feature model, it selects the slope and intercept of a fitted line.
Picture it: Two observed pairs are (items = 0, minutes = 1) and (items = 1, minutes = 3). The line prediction = 1 + 2 * items fits both exactly. Its prediction of 5 minutes at 2 items is extrapolation beyond the observed inputs, not a guaranteed outcome.
What is easy to mix up?
A fit describes an association in the observed data. Causal interpretation needs additional design and assumptions; perfect fit on two points says little about generalization.
Teaching example by Open Agent School. Source: scikit-learn: Ordinary Least Squares.