Pinball loss, also called quantile loss, is an asymmetric loss function that measures how well a forecast estimates a chosen quantile of the target distribution rather than its mean. It penalizes errors on one side of the forecast more heavily than on the other, with the weights set by the target quantile level, usually written as tau. In time series & forecasting, it is the standard objective for training quantile forecasting models and a core metric for evaluating probabilistic forecasts.
The name comes from the shape of the function when plotted against the error: two straight lines meeting at zero with different slopes, resembling the path of a ball bouncing off a pinball flipper. Within artificial intelligence and statistics, the loss traces back to quantile regression, introduced by Koenker and Bassett in 1978.
How pinball loss is defined
For an observed value y, a quantile forecast q and a quantile level tau between 0 and 1, pinball loss equals tau times the error when the actual value lies above the forecast, and one minus tau times the error when it lies below. In compact form, the loss is max(tau * (y - q), (tau - 1) * (y - q)).
This asymmetry is what makes the loss useful. Minimizing expected pinball loss over many observations drives the forecast toward the true tau-quantile of the conditional distribution. At tau equal to 0.5, both slopes are equal, and the loss becomes half the absolute error, so the optimal forecast is the median.
The table below shows how the quantile level changes the penalty for each type of error.
| Quantile level | Weight on under-forecast | Weight on over-forecast | Resulting forecast |
|---|---|---|---|
| 0.1 | 0.1 | 0.9 | Low, conservative bound |
| 0.5 | 0.5 | 0.5 | Median estimate |
| 0.9 | 0.9 | 0.1 | High, cautious bound |
| 0.95 | 0.95 | 0.05 | Upper bound for service levels |
Why the asymmetry produces quantiles
The mechanism is a balance of expected penalties. Suppose the forecast sits at a point where a fraction p of outcomes fall below it. Raising the forecast slightly reduces loss on the outcomes above it at rate tau and increases loss on the outcomes below it at rate one minus tau. The expected loss stops decreasing exactly when p equals tau, which is the definition of the tau-quantile.
This property means pinball loss is a strictly consistent scoring function for quantiles. A forecaster who reports the true quantile minimizes expected loss, so the metric rewards honesty rather than strategic shading. Squared error plays the same role for the mean, and absolute error for the median.
A practical consequence is that the loss has no gradient at zero error and a constant gradient elsewhere. Gradient-based models such as DeepAR variants, the Temporal Fusion Transformer and gradient-boosted trees handle this without difficulty, although some libraries offer a smoothed version near zero for numerical stability.
Pinball loss compared with other forecast metrics
Pinball loss evaluates a single quantile at a time, which distinguishes it from point-forecast metrics and from scores that assess an entire predictive distribution. The following comparison helps select the right metric.
| Metric | What it evaluates | Key property |
|---|---|---|
| Pinball loss | One quantile forecast | Asymmetric, consistent for quantiles |
| Mean absolute error | Median point forecast | Equals twice pinball loss at 0.5 |
| MAPE | Point forecast in percent | Unstable near zero actual values |
| MASE | Point forecast against a naive forecast | Scale-free, comparable across series |
| CRPS | Full predictive distribution | Integral of pinball loss over all quantiles |
| Weighted quantile loss | Several quantiles together | Scaled average of pinball losses |
The link with the continuous ranked probability score is especially useful: averaging pinball loss across a dense grid of quantile levels approximates CRPS. Evaluation suites in the M competitions and in libraries such as GluonTS report scaled or weighted quantile losses for this reason.
Using pinball loss for training and evaluation
In practice, a model is trained to output several quantiles simultaneously, for example 0.1, 0.5 and 0.9, and the training objective is the sum or average of the pinball losses at those levels. The resulting pair of outer quantiles forms an 80 percent prediction interval.
The decision table below matches common business needs with suitable quantile choices.
| Application | Quantile levels | Reason |
|---|---|---|
| Retail inventory planning | 0.9 to 0.95 | Stockouts cost more than surplus stock |
| Perishable goods ordering | 0.5 to 0.7 | Waste limits how high the order can go |
| Electricity load forecasting | 0.05, 0.5, 0.95 | Grid operators need ranges for reserves |
| Cloud capacity planning | 0.99 | Outages are far costlier than idle servers |
When comparing series of different magnitudes, raw pinball loss is scale-dependent. Practitioners therefore divide it by the sum of absolute actual values or by the error of a seasonal naive forecast before aggregating across products or regions.
Limitations and common mistakes
Pinball loss is reliable when used correctly, but several pitfalls recur in forecasting projects. Most of them stem from treating each quantile as independent or from reading the raw number without context.
- Quantile crossing: separately trained quantiles can produce a 0.9 forecast below the 0.5 forecast; sorting outputs or using monotone architectures prevents this.
- Coverage is not checked: a low average loss does not prove that 90 percent of actual values fall below the 0.9 forecast, so calibration should be measured separately.
- Unscaled aggregation: summing raw losses lets high-volume series dominate the score.
- Wrong quantile for the decision: the level should reflect the real cost ratio of under- and over-forecasting, not a habitual default.
- Too few observations at extreme levels: quantiles such as 0.99 need long histories, otherwise estimates become unstable.
A non-technical view
Pinball loss is a way to grade a forecast when one kind of mistake is worse than the other. Imagine a bakery. Running out of bread angers customers. Baking too much wastes a little flour. The bakery cares more about running out.
Pinball loss lets the forecaster say exactly how much more. If running out is nine times worse, the loss punishes low guesses nine times harder. The model then learns to aim high on purpose. The result is a safe estimate, not just an average guess.
A concrete example
A regional grocery chain forecasts daily demand for bottled water across 120 stores. Stockouts during heat waves cost the chain far more than holding a few extra cases, so the analytics team trains a gradient-boosted model with pinball loss at the 0.9 quantile alongside the 0.5 median.
On one store, the median forecast for a Saturday is 400 bottles and the 0.9 forecast is 520. Actual sales reach 480. The 0.9 forecast over-predicted by 40, giving a loss of 0.1 times 40, or 4 points. The median forecast under-predicted by 80, giving 0.5 times 80, or 40 points. Over a summer of evaluation, orders based on the 0.9 quantile cut stockouts sharply while adding only a modest amount of surplus inventory.