Prediction Error

Prediction error compares a prediction with a target.

For a regression target:

error = prediction - target

If:

prediction = 8
target = 5

then:

error = 8 - 5 = 3

The sign tells direction. A positive error means the prediction is above the target. A negative error means it is below the target.

But raw error is not always a good loss. Positive and negative errors can cancel each other across a batch.

errors = [3, -3]
average error = 0

The model was wrong twice, but the average signed error says zero. That is why many losses remove the sign, often by squaring or taking an absolute value.

Exercise: Compute signed error

A model predicts 12, and the target is 9. Compute prediction - target.

Compute it first, then check your number.

HintPrediction minus target

Keep the sign.

SolutionWork it out

prediction - target = 12 - 9 = 3.

Exercise: Notice cancellation

Two examples have signed errors 4 and -4. What is their average signed error?

Compute it first, then check your number.

HintAverage the two errors

Add the errors, then divide by 2.

SolutionWork it out

(4 + (-4)) / 2 = 0 / 2 = 0. The errors cancel even though both examples were wrong.