Online intervals from quantile models: quantile regression and adaptive ensemble CQR¶
Intervals read off a quantile model, refitted or corrected as outcomes arrive.
| Use it when | You have features and want intervals whose width follows them, updated online. |
| Guarantee | QuantileRegressionInterval: none (no calibration step). AdaptiveEnbCQR: approximate, from out-of-bag scores and an ACI step on the level held in [0, 1]. |
| In the library | QuantileRegressionInterval, AdaptiveEnbCQR |
| Source | Koenker and Bassett (1978); Meinshausen (2006); Sousa, Tomé and Moreira (2023), arXiv 2207.14219 |
| Example needs | pyconformal with numba (the default quantile forest) |
Why these are here¶
In the study of conformal prediction for time-series forecasting
(Manokhin, Nurmatov, Sreenivas and Liang 2026, doi:10.5281/zenodo.24715782),
plain quantile regression came 23rd of 66 (rcWIS 1.050) and the adaptive ensemble CQR of Sousa, Tomé and Moreira
25th (1.098). Both take
any model with fit(X, y) and predict(X, quantiles=[...]). With the study's model
(quantile_forest.RandomForestQuantileRegressor(n_estimators=20, min_samples_leaf=5, max_samples_leaf=None)) they give
the study's intervals on 13 series at 11 levels: identical for quantile regression, to 1e-14 for the ensemble
(AdaptiveEnbCQR(..., study=True); by default, from 0.1.10, each revealed outcome adds its plain CQR score to the
window, the same score as the out-of-bag ones, where the study's code subtracted the correction in force). The
default model is pyconformal's own quantile forest, which is several times faster.
Minimal examples¶
Copy, paste, run.
import numpy as np
rng = np.random.default_rng(0)
n = 1400
x = rng.normal(size=(n, 3))
y = x[:, 0] + (0.5 + np.abs(x[:, 1])) * rng.normal(size=n) # the noise depends on a feature
X_train, y_train, X_test, y_test = x[:1000], y[:1000], x[1000:], y[1000:]
Plain quantile regression, refitted every 100 new rows on a sliding window:
from pyconformal import QuantileRegressionInterval
m = QuantileRegressionInterval(alpha=0.1, random_state=0).fit(X_train, y_train)
print(m.predict_interval(X_test[:3])) # (3, 2)
res = m.run(X_test, y_test, alpha=[0.1, 0.2], batch_size=10)
print("coverage", np.round(res.coverage, 3))
Adaptive ensemble conformalized quantile regression:
from pyconformal import AdaptiveEnbCQR
res = AdaptiveEnbCQR(alpha=0.1, n_bootstraps=5, random_state=0).fit(X_train, y_train).run(X_test, y_test, batch_size=10)
print("coverage", round(res.coverage, 3), "mean width", round(float(np.mean(res.intervals[:, 1] - res.intervals[:, 0])), 3))
Speed¶
Full protocol (11 levels, outcomes revealed in batches of 10), the study's code against pyconformal, summed over four series (hourly, five-minute, daily and monthly; 2 cores). "Same model" means the same quantile forest or members, so the gain is in the conformal layer; "own model" swaps in pyconformal's quantile forest.
| Method (place) | Study's code | pyconformal | Speed-up |
|---|---|---|---|
NaiveDiffInterval (21) |
0.47 s | 0.01 s | 65x |
QuantileRegressionInterval (23), same model |
9.7 s | 9.4 s | 1.0x |
QuantileRegressionInterval (23), own model |
9.6 s | 2.2 s | 4.5x |
LaplaceSkater (24) |
15.8 s | 7.9 s | 2.0x |
AdaptiveEnbCQR (25), same model |
31.5 s | 23.9 s | 1.3x |
AdaptiveEnbCQR (25), own model |
31.3 s | 5.4 s | 5.8x |
SFOGD (26) |
0.23 s | 0.03 s | 7.4x |
EnbPI, forest members (27), same model |
77.1 s | 82.5 s | 0.9x |
EnbPI, forest members (27), own model |
77.1 s | 28.2 s | 2.7x |
KOWCPI (28) |
37.0 s | 4.7 s | 7.8x |
SPCI (29), same model |
25.2 s | 23.9 s | 1.1x |
SPCI (29), own model |
25.4 s | 2.8 s | 9.1x |
CPTSD (30) |
21.5 s | 2.9 s | 7.5x |
With the same forests the time is the forests'; pyconformal's quantile forest is where most of the gain comes from.
KOWCPI's kernel quantiles and CPTSD's decompositions are compiled (one STL per step instead of two), and the
quantiles of Laplace's predictive mixtures come from a compiled copy of skaters' own bisection.
Against public packages on one hourly series (benchmarks/speed_places21_30.py, output in
benchmarks/output_speed_places21_30.txt): CPTSD 5x faster than the same method on statsmodels' STL; LaplaceSkater
3x faster than a plain loop over skaters.laplace; with pyconformal's forest instead of quantile-forest's,
QuantileRegressionInterval and AdaptiveEnbCQR 8x, SPCI 9x; EnbPI with pyconformal's forest as members 5x
faster than with scikit-learn's random forest.
More¶
- Methods ranked 31st to 66th in the study: places 31 to 66
- Conformalized quantile regression with a held-out calibration set: CQR
- The default model: quantile forest
- Full argument list: API reference