MAE, MAPE and WAPE when demand contains zeros
In this article (4 sections)
Forecast error metrics embed business choices. Demand with zero-actual periods makes those choices impossible to ignore: absolute percentage error divides by the actual value, so ordinary MAPE is undefined at zero. Silently dropping, replacing or capping those rows changes the evaluation population.
Start from the error at each row, then define the aggregation and its denominator in writing.
- MAE is the mean of absolute errors. It stays in the target’s unit.
- MAPE is the mean of absolute error divided by absolute actual. Every zero actual needs an explicit policy.
- WAPE is total absolute error divided by total absolute actual. It remains calculable when some rows are zero, but fails when the entire denominator is zero.
A four-row counterexample
The verified lab case uses actual demand [0, 0, 10, 20] and two forecasts.
| Forecast | MAE | MAPE on nonzero rows | WAPE |
|---|---|---|---|
A: [0, 5, 8, 18] | 2.25 | 15.0% | 30.0% |
B: [1, 1, 7, 17] | 2.00 | 22.5% | 26.7% |
MAPE prefers A because its calculation excludes the two zero rows, including A’s five-unit error. MAE and WAPE prefer B because they count every absolute error. The disagreement is a consequence of the estimand, not a software defect.
from timeseries_cases import metric_case
result = metric_case()
assert result["forecast_a"]["zero_actual_rows"] == 2
assert result["forecast_b"]["mae"] < result["forecast_a"]["mae"]
assert result["forecast_a"]["mape_nonzero_only"] < result["forecast_b"]["mape_nonzero_only"]
print(result["forecast_a"]["wape"], result["forecast_b"]["wape"])This prints 0.3 and approximately 0.2667.
State the evaluation grain
WAPE across all products weights high-volume items more heavily because their actuals dominate the denominator. Averaging SKU-level WAPEs gives every eligible SKU equal weight and produces another number. Neither aggregation is automatically correct. Choose the grain that matches the decision and show segment results so a good total does not conceal poor low-volume service.
MAE is easy to interpret, but a two-unit error has different business impact for an item selling three units and one selling 3,000. Complement it with scaled measures, cost-weighted loss or service outcomes when those reflect the use case. For intermittent demand, also evaluate stock decisions rather than treating a small average error as proof of availability.
Avoid adding a tiny epsilon to all actuals without a defensible policy. The resulting percentage can be dominated by the chosen constant. Avoid calling MAPE “accuracy”: 100% - MAPE can be negative and does not have the statistical meaning the word suggests.
For every published score, record zero handling, weighting, aggregation grain, horizon and row count. That metadata makes the result reproducible and prevents two dashboards from using the same metric name for different calculations.
The Data Science course develops evaluation as part of the modeling workflow, including failure modes that a single library metric cannot resolve.
Exercise
Create three SKUs: one high-volume, one intermittent and one with all-zero actuals. Calculate portfolio WAPE and per-SKU WAPE. Decide how the all-zero SKU enters the report and document the policy before looking at model rankings.
Continue learning
This article is part of the Forecasting and time-series analysis sequence. Use the neighbouring tasks when you need the prerequisite or the next application.
- Review the prerequisite or neighbouring task in Rolling-origin backtesting with multiple forecast horizons.
- Continue with Decompose a series without confusing trend and seasonality.
Reference: Forecasting: Principles and Practice on forecast accuracy.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Data Science programme — 6 months. From data foundations to machine learning, deep learning and deployment.
Explore Data Science