まとめ
- WAPE measures absolute error relative to the total actual volume.
- Calculate WAPE on demand forecasts and see how it is reported in dashboards.
- Understand instability when total volume is small and how to combine WAPE with MAE.
1. Definition #
$$ \mathrm{WAPE} = \frac{\sum_{i=1}^n |y_i - \hat{y}i|}{\sum{i=1}^n |y_i|} \times 100% $$
- Scales the absolute error by total actuals, making it comparable across items of different magnitude.
- Unlike MAPE, it does not explode when individual actuals hover near zero.
2. Implementation in Python #
import numpy as np
def wape(y_true: np.ndarray, y_pred: np.ndarray) -> float:
"""Weighted Absolute Percentage Error."""
return float(np.sum(np.abs(y_true - y_pred)) / np.sum(np.abs(y_true)))
print("WAPE:", round(wape(y_test, y_pred) * 100, 2), "%")
Guard against cases where the total actual volume is ~0: remove such segments or normalise by mean demand instead.
3. Comparing WAPE and MAPE #
| Metric | Characteristics | Caution |
|---|---|---|
| MAPE | Mean percentage error per sample | Diverges when actual ≈ 0 |
| WAPE | Total absolute error ÷ total actual volume | Heavily influenced by high-volume items |
| sMAPE | Uses average of actual & predicted | Handles zeros but harder to interpret |
WAPE is popular in CPG/retail because it summarises overall demand accuracy without overemphasising low-volume SKUs.
4. Practical usage #
- Inventory planning: track WAPE as a KPI (e.g., target WAPE ≤ 10%). Compare across regions or categories.
- Model comparison: MAE depends on units, but WAPE (percentage) makes models comparable even across different scales.
- Drill-downs: global WAPE can hide poorly performing SKUs—slice WAPE by brand, region, or segment.
5. Caveats #
- If long periods have zero demand, compute WAPE only on active periods or switch to MAE.
- Always evaluate on identical periods and item sets when comparing across time.
- Complement with item-level MAE/MAPE to spot individual problem SKUs.
Summary #
- WAPE expresses absolute error as a share of total demand, making it easy to communicate as a KPI.
- It mitigates MAPE’s zero-demand blow-up, yet still needs MAE/other metrics for item-level diagnosis.
- Combine overall WAPE with segmented views to prioritise improvement work.