StudyBrixFree worksheets, study guides and courses

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.

Make a worksheet

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

  1. Residuals are 1, −1 and 2. Find MSE.

  2. What units does MSE have if the target is measured in metres?

    1. Seconds
    2. Metres only
    3. No units necessarily
    4. Square metres
  3. Which claim is not established by a low regression error alone?

    1. The input causes the target
    2. The evaluated predictions fit the chosen metric
    3. Residuals can be inspected
    4. A baseline comparison is possible
  4. Why can a linear model perform badly when extrapolating far beyond training inputs?

Answers and marking guidance

Answers and marking notes
  1. 2

    (1+1+4)/3=2.

  2. Square metres

    Squared residuals have squared target units.

  3. The input causes the target

    Prediction and causation are different.

  4. 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.