Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.2.0 instead.
Reason given by maintainers: Superseded by version 0.1.1 because the release contained outdated files.

dracp — Dynamic Regime-Aware Conformal Prediction

tests License: MIT

Distribution-free prediction intervals for forecasting when several distribution shifts act at the same time — covariate shift, concept drift, local heterogeneity and latent regimes.

Classical conformal prediction guarantees finite-sample coverage under exchangeability, which sequential economic data routinely violate. Existing adaptive extensions each correct a single departure. DRACP composes four mechanisms inside one weighted-conformal calibration step:

  • density-ratio weighting — corrects a shifted covariate distribution;
  • localized kernel weighting — restores approximate conditional validity, with an automatic floor on the effective sample size;
  • regime-aware weighting — up-weights calibration points from the same latent regime as the query;
  • self-tuning online control — adapts the significance level from realised coverage, aggregating adaptive-conformal experts over several learning rates.

It wraps any point-prediction model: conformal validity does not depend on the model, so keep whatever forecaster you already trust.

Install

pip install dracp

or from source:

git clone https://github.com/bogdanoancea/dracp.git
cd dracp
pip install -e .

Requires Python ≥ 3.10 and the standard scientific stack (NumPy, pandas, SciPy, scikit-learn). Reproducing the paper's experiments additionally needs pip install -e ".[experiments]".

Quick start

import numpy as np, pandas as pd
from sklearn.ensemble import RandomForestRegressor
from dracp import ConformalForecaster

# X, y in chronological order
cf = ConformalForecaster(
        model=RandomForestRegressor(n_estimators=200, random_state=0),
        alpha=0.10)                       # nominal coverage 90%
cf.fit(X_train, y_train)

# Sequential intervals: outcomes are revealed one step at a time,
# so calibration adapts online (recommended for forecasting).
lower, upper = cf.predict_interval(X_test, y_test)

print(cf.score(X_test, y_test))           # coverage, mean width, interval score
cf.predict_frame(X_test, y_test).head()   # tidy DataFrame

Omit y in predict_interval for fixed (non-adaptive) calibration. A complete runnable script is in example_usage.py.

Useful options

Any configuration field can be passed as a keyword argument:

ConformalForecaster(model=..., alpha=0.1,
                    calibration_window=500,   # rolling calibration buffer
                    n_regimes=3,              # latent regimes
                    bandwidth=2.0,            # localization kernel
                    use_faci_control=True,    # self-tuning controller (default)
                    asymmetric=True)          # two-sided quantiles for skewed errors

Baselines included

For benchmarking, the package also implements split, rolling and adaptive (ACI) conformal prediction, and the recent FACI, SAOCP and conformal PID online procedures, all behind the same interface.

Reproducing the paper

The repository ships the full experimental pipeline. Raw data and results are not version-controlled; a single command downloads everything and regenerates every table and figure:

chmod +x run.sh
SEEDS=20 ./run.sh          # setup, synthetic, real, sweeps, montecarlo, report
./run.sh setup real        # or run individual stages

The report stage writes the paper's tables and figures to results/paper/:

python -m reporting.paper_outputs --results-root results --out results/paper

Hyperparameter-sensitivity sweeps (the sensitivity appendix) are produced by

python -m experiments.sensitivity        # resumable; writes results/sweeps_all.csv

The paper-output step regenerates every table body (results/paper/tables/*.tex, ready to \input) and figure (results/paper/figures/*.pdf) reported in the paper, together with key_statistics.json containing the headline numbers (average ranks, win counts, Friedman/Nemenyi statistics, Diebold--Mariano tallies).

Data sources are public: Eurostat (EU-27 HICP inflation), FRED (US macroeconomic and financial series) and UCI (electricity demand).

Citing

If you use this software, please cite both the software (see CITATION.cff, or the archived release DOI) and the paper:

Oancea, B. (2026). Dynamic Regime-Aware Conformal Prediction for Economic Forecasting under Multiple Distribution Shifts.

License

MIT — see LICENSE.

Metadata

Release files for dracp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dracp 0.1.0
File Size Uploaded
dracp-0.1.0.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dracp 0.1.0
File Interpreter ABI Platform
dracp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.2 kB

Release files / dracp-0.1.0.tar.gz

Download URL dracp-0.1.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
df6f91f04ff181047677dbc1815ba4e9a617be4c1c07a85408b2b895beb3cc2c
BLAKE2b-256 checksum
How to use checksums
d4c05398660531beb23ce18d2ecec9ad5c479d070a3593fc26a7ae0f6019e1b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / dracp-0.1.0-py3-none-any.whl

Download URL dracp-0.1.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b852879e672c941493ad69c1ad6648c68e1562ced18f10dd146547ca2245932b
BLAKE2b-256 checksum
How to use checksums
368284834a6ee64991b94e07626aaf457028959fc4fd9523e1401c6ebf7db366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page