Library · Metric

Pinball loss (quantile loss)

The pinball loss, or quantile loss, is the measure for a quantile forecast, such as the stock level that covers demand 90 % of the time. It is minimised by the true quantile and by nothing else.

By , published

Definition

For a target probability τ between 0 and 1, the pinball loss charges τ per unit when the actual value is above the forecast, and 1 − τ per unit when it is below. It comes from quantile regression, introduced by Koenker and Bassett in 1978.

Lτ(y, q) = τ (y − q) if y ≥ q, and (1 − τ) (q − y) if y < q

At τ = 0.9, running short costs nine times more per unit than holding one unit too many. The value of q that minimises the expected loss is the 0.9 quantile of the demand distribution. At τ = 0.5 the loss is half the absolute error and the optimum is the median.

Worked example

Weekly demand follows a Poisson distribution with mean 4. We score every integer stock level at τ = 0.9 and find the one with the lowest average loss.

import numpy as np

rng = np.random.default_rng(1)
demand = rng.poisson(4.0, size=50_000)
tau = 0.9

def pinball(y, q, tau):
    d = y - q
    return np.mean(np.where(d >= 0, tau * d, (tau - 1) * d))

for q in range(3, 10):
    print(f"q = {q}   pinball loss = {pinball(demand, q, tau):.4f}   share of weeks covered = {np.mean(demand <= q):.3f}")
print("empirical 0.9 quantile:", int(np.quantile(demand, tau)))

Output, produced by running the code above when this page was built:

q = 3   pinball loss = 1.2460   share of weeks covered = 0.435
q = 4   pinball loss = 0.7814   share of weeks covered = 0.630
q = 5   pinball loss = 0.5119   share of weeks covered = 0.784
q = 6   pinball loss = 0.3959   share of weeks covered = 0.891
q = 7   pinball loss = 0.3865   share of weeks covered = 0.948
q = 8   pinball loss = 0.4348   share of weeks covered = 0.978
q = 9   pinball loss = 0.5128   share of weeks covered = 0.992
empirical 0.9 quantile: 7

The loss is lowest at the smallest stock level that covers at least 90 % of the weeks, which is the 0.9 quantile. Levels below it are charged for shortages, levels above for excess.

Where it misleads

  • The loss is in the units of the series. To average over items of different sizes it has to be scaled, as in the scaled pinball loss of the M5 uncertainty competition, which divides by the in-sample error of the naive forecast.
  • On count data with small values, many neighbouring quantiles coincide. A loss at a single τ then separates methods poorly, and several levels should be scored together.
  • A good pinball loss at 0.9 does not prove that 90 % of periods are covered. Coverage has to be checked separately.

Averaging the pinball loss over all probability levels gives the CRPS, which scores a whole predictive distribution.

In our work

A stock decision is a quantile, so we score quantiles. On 2,404 spare-part series the scaled quantile loss at 90 % was 0.364 for a Poisson quantile built on a moving average and 0.417 for the same quantile built on SBA: the point forecast underneath mattered more than the distribution placed on top of it.

References

  1. Koenker, R., Bassett, G. (1978). Regression quantiles. Econometrica, 46(1), 33-50. doi:10.2307/1913643
  2. Gneiting, T., Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association, 102(477), 359-378. doi:10.1198/016214506000001437
  3. Makridakis, S., Spiliotis, E., Assimakopoulos, V., Chen, Z., Gaba, A., Tsetlin, I., Winkler, R. L. (2022). The M5 uncertainty competition: results, findings and conclusions. International Journal of Forecasting, 38(4), 1365-1385. doi:10.1016/j.ijforecast.2021.10.009

Have a question like this one on your own data? Tell us what you need in a few lines.

Send us the brief

Related pages

  • CRPS: continuous ranked probability scoreThe CRPS scores a full predictive distribution with one number in the units of the data. For a point forecast it reduces to the absolute error, which makes probabilistic and point forecasts comparable.
  • Prediction interval coverage and the Winkler scoreCoverage is the share of outcomes that fall inside the prediction intervals. It is the first check on any interval, and it needs enough periods to mean something. The Winkler score adds a penalty for the interval width.
  • Service level and fill rateThe cycle service level is the probability that demand is fully met in a period. The fill rate is the share of units demanded that are delivered from stock. They are different numbers, and for slow items they can be far apart.
All library pages