V0.1.22
Features
-
Conformal PID control: New
PIDmethod forConformalIntervals, following Angelopoulos, Candes & Tibshirani (2023). Pooled conformal methods guarantee coverage on average but react slowly when the error scale changes;PIDreplays the calibration windows in time order and tracks the error quantile online (quantile tracking plus error integration), so the intervals follow volatility shifts. It works with every model and is a one-line change. See #102.import pandas as pd from foundationforecast import PID, ConformalIntervals, FoundationForecast from foundationforecast.models import Chronos df = pd.read_csv( "https://timecopilot.s3.amazonaws.com/public/data/air_passengers.csv", parse_dates=["ds"], ) model = Chronos( repo_id="amazon/chronos-bolt-tiny", alias="Chronos-Bolt", prediction_intervals=ConformalIntervals(n_windows=5, method=PID()), ) ff = FoundationForecast(models=[model]) fcst = ff.forecast(df=df, h=12, freq="MS", level=[80, 95])On GOOGL daily open prices (2008 to 2014, 80% intervals, Chronos-Bolt one-step forecasts, 250 calibration windows)
PID(symmetric=True)has a lowest 50-day rolling coverage of 0.68, whileconformal_errordrops to 0.50 (both average about 0.79) and the native Chronos quantiles overcover (0.89). See the new example notebook. -
ConformalMethodbase class:ConformalIntervals.methodaccepts a string (unchanged) or aConformalMethodobject, so parameterized methods likePIDcan be passed directly.PIDandConformalMethodare exported fromfoundationforecast. PIDoptions: asymmetric tails by default (symmetric=Truefor one threshold on the absolute error),integrate=Falsefor quantile tracking only, rolling or expanding learning-rate range, and quantile or zero initialization. Withstep_size < hthe error at horizonjis only usedjobservations after its cutoff. A saturated integrator gives infinite bounds and aUserWarning;ConformalIntervalsrejectsPID()with too few windows at construction.
Fixes
- Docs CI: The docs tests run with all model extras and a fast CIProto changelog example. See #105.
- CIProto attribution: Adds the public attribution required by the ci-proto licence to the README, model hub, example notebook and model docstring. See #104.
Tests
- R cross-check:
tests/core/test_conformal_pid_r.pyreproduces every interval from R'sconformalForecast::pid(asymmetric and symmetric, expanding and rolling, with and without integrator, horizons 1 to 3) to1e-9from a stored fixture, regenerated withtests/core/fixtures/pid_r/generate.py. - PID unit and contract tests: Hand-computed golden values (including delayed feedback), an independent calendar-time oracle, out-of-sample coverage after a variance shift, no future leakage, parameter validation, forecaster integration, and a
test_models.pycontract test.
Documentation
- Conformal under distribution shift notebook:
conformal-distribution-shiftcompares the model's native intervals,conformal_errorandPIDon GOOGL daily prices, with rolling coverage, zoomed windows and a calibration-window sensitivity table. - Conformal prediction guide: New section on PID control: the update rule, every parameter, delayed feedback, the minimum number of windows, the R cross-check, and an M4 Hourly shift experiment.
- Examples navigation: Both conformal notebooks are grouped under Examples > Conformal.
Full Changelog: https://github.com/TimeCopilot/foundationforecast/compare/v0.1.21...v0.1.22