# MAE / Mean absolute error

Mean absolute error (MAE) is a loss function used for regression. The loss is the mean over the absolute differences between true and predicted values, deviations in either direction from the true value are treated the same way.

Example: If the true value is 50 and your model predicts 55, the absolute error for that data point is 5, and if the model had predicted 45, the error would also be 5. The MAE for the whole dataset would be the mean value of all such errors in the dataset.

## Definition

Formula:

$L(y, \hat{y}) = \frac{1}{N} \sum_{i=0}^{N}|y - {\hat{y}}_i|$

where ŷ is the predicted value.

## Why use MAE

MAE is not sensitive towards outliers and given several examples with the same input feature values, the optimal prediction will be their median target value. This should be compared with Mean squared error (MSE), where the optimal prediction is the mean.

## When to use MAE

Use MAE when you are doing regression and don’t want outliers to play a big role. It can also be useful if you know that your distribution is multimodal, and it’s desirable to have predictions at one of the modes, rather than at the mean of them.

## Example of use

When doing image reconstruction MAE encourages less blurry images compared to MSE. This is used for example in the paper Image-to-Image Translation with Conditional Adversarial Networks by Isola et al.