WAPE (Weighted Absolute Percentage Error)

Eval

WAPE (Weighted Absolute Percentage Error)

Created: Last updated: Read time: 2 min
まとめ
  • 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 #

MetricCharacteristicsCaution
MAPEMean percentage error per sampleDiverges when actual ≈ 0
WAPETotal absolute error ÷ total actual volumeHeavily influenced by high-volume items
sMAPEUses average of actual & predictedHandles 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.