Mean Absolute Error

May 20, 2023

In the world of data science and machine learning, being able to accurately predict an outcome is crucial. With machine learning algorithms, we are able to make predictions based on a set of features or inputs. However, the accuracy of these predictions is not always perfect. To quantify the accuracy of these predictions, we use a metric known as mean absolute error (MAE).

Definition

In statistics, mean absolute error is a measure of how far apart a set of actual values are from a set of predicted values. It is defined as the average of the absolute differences between the actual and predicted values.

Mathematically, the formula for mean absolute error is:

\(\)

$$MAE = 1/n * Σ|actual – predicted|$$

where n is the number of observations, Σ is the sum over all observations, and |actual - predicted| represents the absolute difference between the actual and predicted values.

Example

To better understand the concept of mean absolute error, let’s consider a simple example.

Suppose we are asked to predict the sales of a product for the next seven days. We have historical data on the sales of this product for the past month, and we use this data to train a machine learning model that will make predictions for the next seven days.

Our model predicts the following sales for each day:

[10, 9, 12, 8, 11, 10, 13]

However, the actual sales for each day were:

[9, 7, 13, 8, 10, 11, 14]

To calculate the mean absolute error for our predictions, we first calculate the absolute differences between the actual and predicted values for each day:

[|10 - 9|, |9 - 7|, |12 - 13|, |8 - 8|, |11 - 10|, |10 - 11|, |13 - 14|]

which simplifies to:

[1, 2, 1, 0, 1, 1, 1]

We then take the average of these absolute differences to get the mean absolute error:

MAE = (1 + 2 + 1 + 0 + 1 + 1 + 1) / 7 = 1.14

Therefore, our model’s mean absolute error is 1.14.

Interpretation

The mean absolute error tells us how far apart our predictions are from the actual values on average. In our example, a mean absolute error of 1.14 means that, on average, our model’s predictions were off by 1.14 units.

The interpretation of the mean absolute error depends on the context of the problem we are trying to solve. In some cases, a mean absolute error of 1.14 may be considered acceptable, while in other cases it may be considered too high.

Advantages and Disadvantages

One advantage of using mean absolute error as a metric is that it is easy to interpret. It gives us a clear idea of how far apart our predictions are from the actual values on average.

Another advantage is that mean absolute error is not affected by outliers in the data. This is because we take the absolute value of the differences between the actual and predicted values.

However, one disadvantage of using mean absolute error is that it treats all errors equally. This means that a large error and a small error are given the same weight when calculating the mean absolute error. In some cases, this may not be desirable.