Feature scaling
Not met yet
Standardising a column subtracts its mean and divides by its standard deviation, so every feature is centred on 0 with a spread of 1, whatever its units. Gradient descent needs it: one column of big numbers makes the loss steep in its direction, and a rate that suits the others blows that weight up. Work the means and spreads out from the training data only, and scale every new reading with those same numbers. Standardised values aren't squeezed between 0 and 1: anything more than one spread from the mean lands outside.
Try it
main.pyOutput
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks the size of a feature's numbers makes no difference to gradient descent, only what they measure.
- Thinks new readings should be standardised with their own mean and spread, rather than the training data's.
- Thinks standardising squeezes every value between 0 and 1.
- Thinks standardising the features changes the predictions of the least squares fit, rather than only the size of its weights.
- Thinks NumPy refuses to combine columns measured in different units.