Skip to content

V0.1.22

Features

  • Conformal PID control: New PID method for ConformalIntervals, following Angelopoulos, Candes & Tibshirani (2023). Pooled conformal methods guarantee coverage on average but react slowly when the error scale changes; PID replays 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, while conformal_error drops to 0.50 (both average about 0.79) and the native Chronos quantiles overcover (0.89). See the new example notebook.

  • ConformalMethod base class: ConformalIntervals.method accepts a string (unchanged) or a ConformalMethod object, so parameterized methods like PID can be passed directly. PID and ConformalMethod are exported from foundationforecast.

  • PID options: asymmetric tails by default (symmetric=True for one threshold on the absolute error), integrate=False for quantile tracking only, rolling or expanding learning-rate range, and quantile or zero initialization. With step_size < h the error at horizon j is only used j observations after its cutoff. A saturated integrator gives infinite bounds and a UserWarning; ConformalIntervals rejects PID() 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.py reproduces every interval from R's conformalForecast::pid (asymmetric and symmetric, expanding and rolling, with and without integrator, horizons 1 to 3) to 1e-9 from a stored fixture, regenerated with tests/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.py contract test.

Documentation

  • Conformal under distribution shift notebook: conformal-distribution-shift compares the model's native intervals, conformal_error and PID on 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