/ THE IDEA
Let distance be the input and minutes be the output. The rule has a starting value plus an added number of minutes for each kilometre. Training adjusts those two numbers. A residual is the observed answer minus the predicted answer; it preserves whether the prediction was too high or too low. One common fitting rule squares each residual and adds the squares. Squaring prevents a positive error cancelling a negative one, and it makes a large miss count disproportionately. Least squares means choosing the line with the smallest such total, among the candidate lines allowed by the model.
THE FORMAL IDEA
ŷ = a + bx; residual = y − ŷ
| ŷ, read y-hat, is predicted minutes; y is observed minutes. x is distance in kilometres. | | a is predicted minutes at zero distance; b is minutes added per kilometre. A squared residual has units of minutes squared. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Toy records: 1 km took 4 min; 2 km took 6 min. Try ŷ = 1 + 2x: predictions 3 and 5; residuals 1 and 1. Squared-error total = 1² + 1² = 2. Change a from 1 to 2: predictions 4 and 6; total becomes 0.
|
Changing only the starting value moves both predictions together. Here that fixes both misses because the toy records happen to lie on the same straight line. With many noisy records, moving the line to improve one prediction may worsen another; the total provides a consistent comparison.
/ SO WHAT?
Residuals are also useful after fitting. If long trips are repeatedly underestimated while short trips are overestimated, their pattern suggests the rule is missing structure. A single average error can hide that pattern because opposite signs cancel. Inspecting the mistakes tells you something different from inspecting the final fitted coefficients.
ONE CAVEAT |
| A straight line may be inappropriate, and unusual records can strongly influence squared-error fitting. A zero training error on two invented journeys does not establish reliable predictions for unfamiliar distances or future traffic. |
KEEP THIS
A fitted line balances errors according to its scoring rule, so changing how errors are counted can change the learned prediction.
|
NEXT: What makes twice the voltage mean twice the flow?
|