Skip to main content
OnlineCML

Causal inference for the real world — one observation at a time.

CI
Coverage Docs

Why OnlineCML?

Every major causal inference library (EconML, CausalML, DoWhy) requires a complete dataset before you begin. But many real-world applications don't have that luxury:

  • A/B tests where you want decisions now, not after 30 days
  • Clinical trials where treatment effects must be monitored continuously
  • Marketing systems where customer data arrives as a stream
  • Any setting where the treatment effect might shift over time

OnlineCML processes one observation at a time. No batches. No waiting.

Installation

pip install onlinecml

Quickstart

from onlinecml.datasets import LinearCausalStream
from onlinecml.reweighting import OnlineIPW

estimator = OnlineIPW()
for x, treatment, outcome, _ in LinearCausalStream(n=1000, true_ate=2.0, seed=42):
    estimator.learn_one(x, treatment, outcome)

print(f"ATE:   {estimator.predict_ate():.3f}")  # → ~2.0
print(f"95%CI: {estimator.predict_ci()}")

Methods

Method Class ATE Individual CATE Doubly Robust
Inverse Probability Weighting OnlineIPW ✓ — —
Augmented IPW OnlineAIPW ✓ ✓ ✓
Overlap Weights OnlineOverlapWeights ✓ — —
S-Learner OnlineSLearner ✓ ✓ —
T-Learner OnlineTLearner ✓ ✓ —
X-Learner OnlineXLearner ✓ ✓ —
R-Learner OnlineRLearner ✓ ✓ —
Online Matching OnlineMatching ✓ ✓ —
Caliper Matching OnlineCaliperMatching ✓ ✓ —
Causal Hoeffding Tree CausalHoeffdingTree ✓ ✓ ✓
Online Causal Forest OnlineCausalForest ✓ ✓ ✓

Novel contributions: CausalHoeffdingTree and OnlineCausalForest implement a custom causal split criterion that maximises between-child CATE variance rather than outcome MSE, with linear leaf models, doubly robust correction, multi-threshold split search, and per-tree ADWIN drift detection.

Policies: EpsilonGreedy, ThompsonSampling, UCB

Diagnostics: OnlineSMD, ATETracker (with convergence plot and forgetting factor), OverlapChecker, ConceptDriftMonitor

Datasets: LinearCausalStream, HeterogeneousCausalStream, DriftingCausalStream, UnbalancedCausalStream, ContinuousTreatmentStream

Evaluation: progressive_causal_score, PEHE, ATEError, UpliftAUC, QiniCoefficient

How it differs from batch libraries

DoWhy EconML CausalML OnlineCML
Online / streaming ✗ ✗ ✗ ✓
One-obs-at-a-time ✗ ✗ ✗ ✓
Concept drift ✗ ✗ ✗ ✓
Exploration policy ✗ ✗ ✗ ✓
River compatible ✗ ✗ ✗ ✓
Online causal forest ✗ ✗ ✗ ✓
IPW / DR / Overlap ✓ ✓ ✓ ✓
Meta-learners ✓ ✓ ✓ ✓
CATE estimation ✓ ✓ ✓ ✓

Documentation

Full documentation and example notebooks at athammad.github.io/onlinecml.

Contributing

See CONTRIBUTING.md. All PRs require unit tests and must maintain >90% coverage.

Citation

@software{onlinecml2025,
  title  = {OnlineCML: Online Causal Machine Learning in Python},
  author = {Hammad, Ahmed},
  year   = {2025},
  url    = {https://github.com/athammad/onlinecml}
}

License

MIT

Metadata

Release files for onlinecml 1.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 onlinecml 1.1.0
File Size Uploaded Provenance Actions
onlinecml-1.1.0.tar.gz 53.0 kB With provenance Details for onlinecml-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 130.8 kB

Release files / onlinecml-1.1.0.tar.gz

Download URL onlinecml-1.1.0.tar.gz
Size 53.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e9cf226943de6c78c3a95e6df654f8d7e001ee8a12b01295c608c46852e4f1cb
BLAKE2b-256 checksum
How to use checksums
81773b05b85f5b03a8233227b526af1e0e3167cb7dbac0ddeba65b9b645c827e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 23, 2026.

Transparency log

Release files / onlinecml-1.1.0-py3-none-any.whl

Download URL onlinecml-1.1.0-py3-none-any.whl
Size 77.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63de96206fc3f7fd5864d35bd960f07d8c7c0d2c39bb1d0f1f55d28707f4cd19
BLAKE2b-256 checksum
How to use checksums
d2b90cf2fdeef9a5bbf5783860657c361984094ebce2f868163819d968b0b437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 23, 2026.

Transparency log

Security for onlinecml 1.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for onlinecml-1.1.0.tar.gz

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 Apr 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

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