Machine Learning Basics
A straight line y = ax + b is fitted by least squares to the three data points (x, y) = (1, 3), (2, 4) and (3, 8). What is the predicted value at x = 4?
- A10
- B10.5
- C12
Show answer and explanation
Answer: A. 10
Least squares chooses a and b so that the sum of the squared differences (residuals) between the actual values and the line is as small as possible. The mean of x is 2 and the mean of y is 5, so the slope is a = Σ(x − 2)(y − 5) ÷ Σ(x − 2)² = (2 + 0 + 3) ÷ 2 = 2.5 and the intercept is b = 5 − 2.5 × 2 = 0. The predicted value at x = 4 is therefore 2.5 × 4 = 10.
- A. Correct. The regression line is y = 2.5x, so the prediction is 2.5 × 4 = 10.
- B. This is the prediction of the line y = 2.5x + 0.5 through the first and last points, (1, 3) and (3, 8). Least squares takes the residuals of all three points into account.
- C. This extends the line through the last two points, (2, 4) and (3, 8).