Quantile regression is a regression method that estimates a chosen conditional quantile of the target variable, such as the median or the 90th percentile, instead of the conditional mean. In machine learning, it is the standard way to model the spread and shape of outcomes, to build prediction intervals and to make decisions that depend on worst cases or best cases rather than on averages.
The approach was formalized in econometrics in 1978 and now appears in linear models, gradient boosting, random forests and neural networks. Its core idea is simple: replace the squared error with an asymmetric loss function whose minimizer is the desired quantile.
How the pinball loss targets a quantile
Quantile regression minimizes the pinball loss, also called the check loss or quantile loss. For a quantile level tau between 0 and 1 and a residual u equal to the observed value minus the prediction, the loss equals tau times u when u is positive and (tau minus 1) times u when u is negative.
This asymmetry is the whole mechanism. At tau of 0.9, underpredicting costs nine times as much as overpredicting by the same amount, so the optimal prediction rises until only about 10 percent of observations lie above it. At tau of 0.5 the penalties are equal, and the method reduces to least absolute deviation regression, which estimates the conditional median.
The table below shows how the choice of tau changes the penalty balance and the meaning of the prediction.
| Quantile level | Penalty for underprediction | Penalty for overprediction | Prediction represents |
|---|---|---|---|
| 0.1 | 0.1 per unit | 0.9 per unit | Low scenario, 10 percent below |
| 0.5 | 0.5 per unit | 0.5 per unit | Conditional median |
| 0.9 | 0.9 per unit | 0.1 per unit | High scenario, 90 percent below |
| 0.99 | 0.99 per unit | 0.01 per unit | Extreme upper tail |
In the linear case, the optimization problem is a linear program, solved with simplex-type or interior-point methods. Because the loss is not differentiable at zero, gradient-based learners use a subgradient or a smoothed approximation of the pinball loss.
Why model quantiles instead of the mean
Quantile regression is valuable whenever the average hides the information that matters. Ordinary least squares describes only the center of the conditional distribution, while a set of quantile models describes how the whole distribution moves with the features.
- Heteroscedastic data: when variance grows with a feature, upper and lower quantile lines diverge, which reveals that the uncertainty itself depends on the input.
- Robustness to outliers: the median model is far less sensitive to extreme target values than a mean model.
- Asymmetric costs: inventory, capacity and risk decisions often care about a high percentile, not the expected value.
- Distribution-free intervals: no Gaussian assumption about the errors is required.
A pair of models at tau of 0.05 and 0.95 produces a nominal 90 percent prediction interval. This is often simpler and more honest than deriving intervals from a mean model with an assumed error distribution.
Quantile regression across model families
Almost any learner that accepts a custom loss can perform quantile regression. The families differ in flexibility, speed and how naturally they produce several quantiles at once.
| Model family | How quantiles are obtained | Strengths | Limitations |
|---|---|---|---|
| Linear quantile regression | Linear program with pinball loss | Interpretable coefficients per quantile | Assumes linear effects |
| Gradient boosting | Pinball loss as the training objective | Strong accuracy on tabular data | One model per quantile in most libraries |
| Quantile regression forests | Empirical quantiles of leaf observations | All quantiles from one forest | Large memory footprint |
| Neural networks | Several outputs, each with its own pinball loss | Shared representation, many quantiles | Needs care to prevent crossing |
Linear models give separate coefficients for each quantile, which is useful for explanation: a feature may have little effect on the median yet a large effect on the 95th percentile. Tree ensembles and neural networks trade that interpretability for the ability to capture nonlinear interactions.
Evaluating quantile predictions
Quantile models need evaluation metrics that match their purpose. Mean squared error is not appropriate, because it rewards predictions near the mean rather than near the target quantile.
| Metric | What it measures | Good result |
|---|---|---|
| Average pinball loss | Accuracy at a specific quantile | Lower is better |
| Empirical coverage | Share of targets below the predicted quantile | Close to tau |
| Interval coverage | Share of targets inside an interval | Close to the nominal level |
| Interval width | Sharpness of the interval | Narrow at correct coverage |
Coverage and width must be read together. A very wide interval achieves perfect coverage but is useless, so the goal is calibrated coverage with the narrowest possible interval, checked on a held-out test set and, ideally, within important subgroups.
Limitations and common mistakes
The most cited problem is quantile crossing: separately trained models can predict a 90th percentile below the 80th percentile for some inputs. Remedies include sorting the predicted quantiles, joint training with monotonic constraints or using a single model that outputs ordered quantiles.
Extreme quantiles are hard to estimate because few observations fall in the tails. Estimates at tau of 0.99 have high variance unless the dataset is large, and they cannot extrapolate beyond the observed range. Nominal coverage also tends to degrade under distribution shift or concept drift.
When guaranteed coverage is required, practitioners often apply conformalized quantile regression, which adjusts the quantile predictions with residuals from a calibration set. This keeps the adaptive width of quantile models while restoring finite-sample coverage guarantees under exchangeable data.
In plain words
Most prediction models give one number, the average. Quantile regression gives a number with a chosen level of caution. It can answer questions such as “what is the highest value we should reasonably expect”.
Think of a commute. The average trip may take 30 minutes. On bad days it takes 50. Quantile regression can predict that 50-minute figure directly. Predicting a low and a high value together gives a range that shows how uncertain the forecast is.
A real-world example
A regional grocery chain forecasts daily demand for fresh bread in each of its 120 stores. Running out loses sales and customer goodwill, while unsold bread is discarded, and the finance team estimates that a stockout costs about four times as much as a leftover loaf.
Instead of forecasting average demand, the data team trains a gradient boosting model with pinball loss at tau of 0.8, which matches that cost ratio. Features include weekday, holidays, weather and recent sales. Stores order the predicted 80th percentile each morning. On a held-out quarter, about 79 percent of days stay at or below the order quantity, and the chain reduces stockouts substantially without a large increase in waste, because the quantile adapts to volatile weekends and stays lean on stable weekdays.