Mean square error and mean absolute error

Created
TagsLoss

MSE = np.mean((ytrue - ypred)**2)

MAE = np.mean(abs( ytrue- ypred))

MSE=1Ni=1n(targetipredictioni)2MSE=\frac{1}{N}\sum_{i=1}^n (\text{target}_i - \text{prediction}_i)^2

MAE=1Ni=1ntargetipredictioniMAE = \frac{1}{N} \sum_{i=1}^n|\text{target}_i - \text{prediction}_i|

In practice, we always need to look for the outlier. If we have an outlier in our data, it will make the MSE loss model give more weight to the outlier than a MAE loss model. In that case, using MAE loss is more intuitive since it’s more robust to an outlier.