Mean squared logarithmic error

Mean squared logarithmic error (MSLE) is, as the name suggests, a variation of the Mean Squared Error. The loss is the mean over the seen data of the squared differences between the log-transformed true and predicted values, or writing it as a formula:

Mean squared logarithmic error

where ŷ is the predicted value.

This loss can be interpreted as a measure of the ratio between the true and predicted values, since:

mage::MSLE_02.png[Ratio between the true and predicted values]

The reason ‘1’ is added to both y and ŷ is for mathematical convenience since log(0)is not defined but both y or ŷ can be 0.

Why use Mean squared logarithmic error

The introduction of the logarithm makes MSLE only care about the relative difference between the real and the predicted value, or in other words, it only cares about the percentual difference between them. This means that MSLE will treat small differences between small true and predicted values approximately the same as big differences between large true and predicted values:

y y-ŷ y-ŷ y+1ŷ+1 \frac{y+1}{ŷ+1} MSE MSLE

30

20

10

1.47619

100

0.02861

30000

20000

10000

1.49998

100 000 000

0.03100

big difference

small difference

big difference

small difference

MSLE also penalizes underestimates more than overestimates, introducing an asymmetry in the error curve:

y y-ŷ y-ŷ y+1ŷ+1 \frac{y+1}{ŷ+1} MSE MSLE

20

10

10

(underestimate)

1.90909

100

0.07886

20

30

-10

(overestimate)

0.67742

100

0.02861

no difference in the size of the error

big difference

no difference

big difference

When to use Mean squared logarithmic error

Use MSLE when doing regression, believing that your target, conditioned on the input, is normally distributed, and you don’t want large errors to be significantly more penalized than small ones, in those cases where the range of the target value is large.

Example: You want to predict future house prices, and your dataset includes homes that are orders of magnitude different in price. The price is a continuous value, and therefore we want to do regression. MSLE can here be used as the loss function.

Try the platform