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: 0.1.1. will be superseded by the following version

dracp — Dynamic Regime-Aware Conformal Prediction

tests License: MIT DOI PyPI

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.1

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.1
File Size Uploaded
dracp-0.1.1.tar.gz 21.6 kB Details

Built distribution (wheel)

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

Total release size: 43.4 kB

Release files / dracp-0.1.1.tar.gz

Download URL dracp-0.1.1.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d548cc9905c238fdbe6db59b6595a3c3245424cf77fad15f34f588d1f25deecd
BLAKE2b-256 checksum
How to use checksums
d9751da4caf2f72ffbd06c94f8795f3a93564de1460d224305658299239ad481
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 30, 2026.

Transparency log

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

Download URL dracp-0.1.1-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
458ea02e13f2e4f29edb20e30c6af0ebc41ad36e0c6565a870b749002bacc3ca
BLAKE2b-256 checksum
How to use checksums
4a03f84cadbe52e71bdd59111865e0ea59e21e250c0610e1262201a6b1f37e5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 30, 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

This release

0.1.1 This release

2 release files

0.1.0

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