Predict with a line
Fit the straight line that sits closest to all the points, then use it to predict a score from hours of study.
A strong pattern can be turned into a prediction. Draw the straight line that fits the cloud best and read new answers off it.
The line of best fit
A straight line is , where is the slope (marks per extra hour) and is where it starts at 0 hours. The best line makes the total of the squared vertical gaps between the points and the line as small as possible: the least-squares line.
Each extra hour of study goes with about 5 to 6 more marks. Slide the hours in the model and the yellow ball reads the same predictions off the black line.
How far to trust it
- Inside the data (0 to 10 hours) predictions are fair guesses, give or take the scatter, about ±6 marks here.
- Outside the data the line keeps going but reality does not. At 20 hours the line predicts over 130 marks out of 100.
- The line describes this class. Another school, another test, another line.
This is exactly what a machine learning model does at its simplest: find the line, or curve, that fits past examples, then use it on new ones.
What to remember
- The least-squares line minimises the squared gaps between points and line.
- Its slope is the expected change in output per unit of input.
- Predictions are reasonable inside the range of the data and unreliable outside it.
- Fitting a line to examples is the simplest form of machine learning.