ergodic
Causal AI in one Python package. ergodic learns causal graphs from data, tells you
whether a question can be answered from them, and estimates the effect with an
interval. It also covers quasi-experiments on panels, process mining on event logs,
structural causal models, and Bayesian forecasting with drivers. ergodic runs
locally; the optional [welt] extra calls the hosted Welt service. ergodic is
pre-1.0, so the API can change between minor versions.
Documentation: docs.ergodic.dev
Install
pip install "ergodic"
# or
uv add "ergodic"
Requires Python 3.11 or later. The extras "ergodic[scm]", "ergodic[forecast]" and
"ergodic[latent]" add PyMC for structural causal models, forecasting and hidden
regimes. "ergodic[welt]" connects to
Welt, which runs hosted models on your data.
Your first causal effect
from ergodic import discover, estimate_effect, identify_effect
from ergodic.datasets import load_earthquake
alarm = load_earthquake(n=10_000, seed=0) # the burglar-alarm network (Pearl, 1988)
graph = discover(alarm.data, method="pc").graph # learn the graph from data alone
for edge in sorted(edge.glyph() for edge in graph.edges):
print(edge)
print(identify_effect(graph, "Burglary", "JohnCalls")) # can the data answer it?
print(estimate_effect(graph, alarm.data, "Burglary", "JohnCalls", treated="True"))
Alarm --> JohnCalls
Alarm --> MaryCalls
Alarm <-- Burglary
Alarm <-- Earthquake
Identification(adjustment: P(JohnCalls | do(Burglary)) = sum_z P(JohnCalls | Burglary, z) P(z), with z = {Earthquake})
EffectEstimate(aipw, analytic: ate=0.7982, se=0.0333, 95% CI [0.733, 0.863], n=10000)
The true effect, from the network's own tables, is 0.793: inside the interval. The documentation starts from this program and goes step by step.
Links
- Documentation
- Welt: hosted models for prediction, causal discovery and forecasting
- Changelog, contributing, security
Licence
Metadata
Release files for ergodic 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ergodic-0.3.0.tar.gz | 2.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ergodic-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.4 MB
Release files / ergodic-0.3.0.tar.gz
| Download URL | ergodic-0.3.0.tar.gz |
|---|---|
| Size | 2.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15aaf476ba63a89113ece029ff58d3ef879fc06c6ad7c13ae7f0501902b6d26c
|
|
BLAKE2b-256 checksum How to use checksums |
f4e1484ef43dea92bb3121c18355a6fbf7668603eab022109c06eb7773613021
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|
Release files / ergodic-0.3.0-py3-none-any.whl
| Download URL | ergodic-0.3.0-py3-none-any.whl |
|---|---|
| Size | 883.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
227281d4e10715c523d9902a53543b672cf6e20272f2d8d041546f2c42092255
|
|
BLAKE2b-256 checksum How to use checksums |
f8082a88ec2b252c7ada3482610d119e479ce6e6516c682a4eeb3e1fb4620e85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|