
An ETA service promises a conservative arrival window. Underestimation and overestimation have different consequences for the passenger waiting at the pickup point. At alpha 0.9, the loss assigns a larger penalty to underprediction. This supports evaluation of a high conditional quantile forecast.
A small worked example
The observations are invented so the arithmetic can be checked independently of model training. In application logs, keep a stable record ID beside each prediction, plus the time at which the eventual outcome became known.
from sklearn.metrics import mean_pinball_loss
def evaluate(v):
return mean_pinball_loss(v[0],v[1],alpha=.9)
for sample in [[[10, 20], [8, 18]], [[10, 20], [12, 22]], [[10, 20], [10, 20]]]:
print(evaluate(sample))How to read the result
| Example input | Calculated output |
|---|---|
| [[10, 20], [8, 18]] | 1.8 |
| [[10, 20], [12, 22]] | 0.2 |
| [[10, 20], [10, 20]] | 0.0 |
For [[10, 20], [8, 18]], the observed output is 1.8. With [[10, 20], [12, 22]], it becomes 0.2. A UI screenshot alone would discard some of this evidence. Keep the original data, the expected return value and the runtime version together when filing a regression report.
The value for [[10, 20], [10, 20]] is 0.0. Record the unit or indexing convention next to that expectation. A second implementation can return the same type and still disagree about where a boundary falls or which observations enter the calculation.
The second case changes the reported quantity by -1.6 compared with the first. That is an absolute difference in the reported scale. Calling it a relative percent change would require dividing by an appropriate starting value and handling a baseline of zero.
How to test the real system
A quantile prediction is not a promise that every interval will cover the outcome. Check empirical coverage on held-out trips.
For a repeatable comparison, retain one counterexample as well as one ordinary success. In this fixture, [[10, 20], [12, 22]] makes a useful starting point: its reference result is 0.2. A changed result is a prompt to inspect the inputs, dependency version and chosen policy before accepting a new baseline.
A reproduction of pinball loss should keep the measurement unit with the case. Here the original first input is [[10, 20], [8, 18]]. In a production note, include the source of the observed target and the unit stored for it. This makes it possible to tell a code regression apart from a target that changed between data collections when the same evaluation is run again.
scikit-learn mean pinball loss · Python numeric types
Sources and further reading
Cover photograph: Top view of Lenovo ThinkPad X220 keyboard bezel by Siarhei Besarab. CC BY-SA 4.0. Cropped and typeset for this cover. The photograph illustrates the topic. This image adaptation uses the same share-alike license.
