MAPE (Mean Absolute Percentage Error) is an error metric used to measure the performance of regression machine learning models. It is a popular metric to use amongst data scientists as it returns the error as a percentage, making it both easy for end users to understand and simpler to compare model accuracy across use cases and datasets.

## What is MAPE | Data Science Interview Questions

## Why is MAPE important?

MAPE is an important metric thats easy to interpret. It depends specifically on the data youre evaluating, providing an accurate assessment of the reliability of your forecast. Based on the MAPE, your organization can develop more accurate forecasts for future projects, properly adjusting costs for materials and labors and ensuring you can best align your production and operations with customer demands.

## What is MAPE?

Mean absolute percentage error (MAPE) measures the accuracy of the forecasting method an organization used. It represents the average of the absolute percentage errors of each entry in a dataset, showing, on average, how accurate the forecasted quantities were in comparison with the actual quantities. MAPE is often effective for analyzing larger sets of data, but its not possible to calculate the MAPE of datasets with zero values. This is because the calculation would require dividing by zero, which is impossible.

MAPE is a straightforward metric, meaning a 10% MAPE represents the average deviation between the forecasted value and actual values was 10%, regardless of whether the deviation was positive or negative. However, theres no industry standard for whats considered to be a good MAPE. For example, an organization that changes prices frequently or offers promotions often may have a higher MAPE than an organization with consistent pricing does. This is because changes in pricing may make it challenging to forecast sales accurately, but both organizations may still be successful.

## What is forecast error?

Forecast error refers to the actual quantity and how it deviates from the forecasted quantity. The error may be bigger than the actual quantity or the forecasted quantity, but it cannot be larger than both. Heres the formula to use for calculating forecast error:

Forecast error = | actual – forecast |

In this equation, the bars represent using the absolute value, meaning the outcome of the equation will always be positive regardless of whether the actual amount is actually less than the forecast. Forecast error focuses on the magnitude of the error, not if its positive or negative. In order to calculate MAPE, its important to calculate the forecast error percent. Heres the formula for calculating forecast error percent:

Forecast error percent = [(| actual – forecast | ) / actual] x 100

The forecast error percent best represents the accuracy of the forecast. If the forecast error percent is close to or above 100%, this indicates the forecast is entirely or very inaccurate. Conversely, if the forecast error percent is closer to 0%, this indicates the forecast is accurate.

## How to calculate MAPE

Here are the steps to follow for how to calculate MAPE:

**1. Organize your data**

Gather and organize your data to best visualize the actual and forecasted values within your dataset. Consider using a spreadsheet program that allows you to create columns for each time period, the actual values and the forecasted values. Placing each value side by side allows you to compare information and complete calculations easily.

**2. Calculate the absolute percent error**

After organizing your data, calculate the absolute percent error for the actual amount versus the forecasted amount for each data entry. Repeat for each row in your dataset. Heres the formula you can use:

Absolute percent error = [( | actual – forecast | ) / | actual | ] x 100

The bars in the equation represent determining the absolute value of the difference between the actual amount and the forecasted about. Absolute value means using the positive value of a number regardless of a result of a calculation, and its used for MAPE because the concern is how significant the difference is, not whether its positive or negative. For example, if the actual number of goods sold is 54, but the forecasted number was 65, youd have a difference of -11. However, with the absolute value, youd use 11 to finish the calculations for an absolute percent error of 20.37%.

**3. Calculate the MAPE**

Once you have the absolute percent error for each data entry, you can calculate the MAPE. Add all the absolute percent errors together, then divide the sum by the number of errors. For example, if your dataset included 12 entries, you would divide the sum by 12. The final result is the MAPE.

## Example of how to calculate MAPE

Heres an example of how to calculate MAPE:

Edwards High School wants to calculate the MAPE of their yearbook orders for the previous school year. They expected to sell 400 yearbooks, but only sold 386. They use the following table to organize the actual number of yearbooks ordered per month, the forecasted number of yearbooks ordered per month and the absolute percent error of each months yearbook orders:

To determine the MAPE, they determine the sum of the absolute percent error for each month. Once they have a sum of 100.18, they divide this number by nine for the nine months of the school year. As a result, the MAPE is 11.13%.*