Artificial intelligence · University
Linear regression, residuals and squared loss
A linear model predicts yhat=w·x+b. Linear refers to the parameters; feature transformations may make the relation nonlinear in original inputs.
Prerequisites
Algebra, averages and basic derivatives.
Study notes
Prediction
A linear model predicts yhat=w·x+b. Linear refers to the parameters; feature transformations may make the relation nonlinear in original inputs.
Residual
Define residual consistently, for example yhat−y. Squared loss penalizes larger residuals more heavily.
Mean loss
MSE is the mean squared residual over the evaluated examples. It has squared target units and is not the same as mean absolute error.
Interpretation
Good fit on observed data does not establish causation or reliable extrapolation. Inspect residual patterns and the intended data range.
Worked examples
For yhat=2x+3 and x=4, calculate the prediction.
2×4+3=11.
11
For prediction 7 and target 5, calculate squared error.
(7−5)²=4.
4
Check your understanding
Residuals are 1, −1 and 2. Find MSE.
What units does MSE have if the target is measured in metres?
- Seconds
- Metres only
- No units necessarily
- Square metres
Which claim is not established by a low regression error alone?
- The input causes the target
- The evaluated predictions fit the chosen metric
- Residuals can be inspected
- A baseline comparison is possible
Why can a linear model perform badly when extrapolating far beyond training inputs?
Answers and marking guidance
Answers and marking notes
- 2
(1+1+4)/3=2.
- Square metres
Squared residuals have squared target units.
- The input causes the target
Prediction and causation are different.
- The assumed relation may not hold outside the observed region and the training data may not constrain that behaviour.
Credit model assumptions and data support.
Further reading and review references
These are reference links, not copied exercises, institutional endorsement or proof of independent review.
AI-assisted preview; independent educational review required. Level labels describe prerequisites, not accreditation or official curriculum alignment.