Identification-first causal inference: discovery, identification, estimation, interventions, and counterfactuals under structural uncertainty
Project description
Antecedent
Antecedent is an identification-first causal inference engine for Python (with a native Rust core). It takes an analysis from causal structure through estimation, diagnostics, interventions, and counterfactuals — without silently treating discovered graphs as ground truth.
Use it when you need a causal effect you can defend: identification is checked before anything is estimated, refuters run against the estimate by default, and uncertainty about the causal graph — a CPDAG, a PAG, a posterior over graphs — is carried through to the effect instead of being resolved by fiat.
Requires CPython 3.11–3.14. Install from PyPI:
pip install antecedent
Paste this block and run it. It simulates a confounded dataset, checks that the effect is identified, estimates it, and runs refuters against the estimate:
import numpy as np
from antecedent import AverageEffect, analyze
rng = np.random.default_rng(0)
n = 2000
season = rng.normal(size=n) # confounder
price = 0.7 * season + rng.normal(size=n) # treatment
sales = 1.5 * price + 2.0 * season + rng.normal(size=n) # outcome, true effect = 1.5
result = analyze(
data={"season": season, "price": price, "sales": sales},
graph=[("season", "price"), ("season", "sales"), ("price", "sales")],
query=AverageEffect(treatment="price", outcome="sales"),
)
print(result.identification) # NonparametricallyIdentified via backdoor.adjustment, adjusting for season
print(result.estimate) # ate=1.48, analytic and bootstrap standard errors
print(result.validation) # refuters ran and passed
The same analyze() call scales from this to temporal pulse effects,
Bayesian graph-posterior mixtures that report unidentified structure mass,
mediation, counterfactuals, and root-cause attribution — see the
project README for worked
examples and the documentation for the
full API.
Development
For local development you need a Rust 1.85 toolchain. CI builds and smoke-tests
wheels for the supported CPython range on Linux x86_64/aarch64 (manylinux),
macOS arm64, and Windows x86_64 (default faer path; no system BLAS). Tagged
releases publish wheels to PyPI and GitHub Release assets (see
docs/development.md).
cd python
uv venv && source .venv/bin/activate
uv sync --group dev
maturin develop
pytest
Lint and types (local gate only — not part of wheel CI):
bash ../scripts/gate_python_lint.sh # ruff check/format + mypy
Public API
Primary entry point is the OO facade:
import antecedent
g = antecedent.Dag.from_edges(["z", "t", "y"], [("z", "t"), ("z", "y"), ("t", "y")])
result = antecedent.analyze(
data, # dict[str, array] or pandas DataFrame
graph=g, # or an edge list
query=antecedent.AverageEffect(treatment="t", outcome="y"),
inference=antecedent.Frequentist(), # or antecedent.Bayesian(...)
)
print(result.identification, result.estimate, result.validation)
# Identify without estimating:
id_only = antecedent.identify(
graph=g,
query=antecedent.AverageEffect(treatment="t", outcome="y"),
identifier=antecedent.Identifier.BACKDOOR_ADJUSTMENT,
)
gcm = antecedent.fit_gcm(["z", "t", "y"], columns, list(g.edges()))
draws = gcm.sample_do({"t": 1.0}, n=200)
# Or discover then fit (never invents orientations; refuses incomplete PAG/FCI):
fitted, edges = antecedent.fit_gcm_discovered(data, discovery=antecedent.PC(alpha=0.05))
Also exposed:
- Typed graphs:
Dag/Cpdag/Pag/Admg/TemporalDag(d_separated/latent_projectonDag;m_separatedonAdmg/Pag) Identifier/Estimatorenums (wire ids) plus string kwargsidentify(graph=…, query=AverageEffect(…))— identify without estimating- Queries:
AverageEffect,MediationEffect,Counterfactual,PulseEffect,SustainedEffect,InterventionalDistribution,PathSpecificEffect,ConditionalEffect,TemporalMediationEffect discover_*(PC, GES, LiNGAM, NOTEARS, FCI/RFCI, PCMCI family, Bayesian posteriors)validate_pcmci_*/ discovery stability validators (block bootstrap, FPR, grids, …)FittedGcm/counterfactual_ite/sample_do/mechanism_kinds— GCM counterfactualsPopulationRegistry/target_*helpers for named predicates and custom-distribution IPWfit_gcm_discovered/attribute_*_discovered— discover-then-attribute compositionCausalState— incremental state with retained batches, events, suff-stats, and particle filterrefute=True|"full"|"placebo"|Falseon static and temporalanalyze- RD:
estimator="rd.sharp"withrunning_variable/cutoff/bandwidth dag_from_*/dag_to_*— graph interchange (alsoDag.from_dot/.to_dot)- Design / state examples:
examples/rank_designs.py,examples/causal_state_workflow.py(see ADR 0016 — no auto-rerun)
Build artifacts (_native.*.so) are gitignored; always maturin develop (or install a wheel) on a fresh checkout.
Typed exceptions (CausalError and subclasses) mirror Rust CausalError categories.
The native module antecedent._native remains available for advanced FFI use
(including the flat AteAnalysisResult DTO; prefer nested AnalysisResult).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file antecedent-0.3.0-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a1c9d6eb9006b0207a29f1097762131a28b80a81d9ac0d3ce1150c74aefb491
|
|
| MD5 |
ddcc7d24af8f9596f4da0b948e7a890f
|
|
| BLAKE2b-256 |
900aad409487b2283144db3a0b985b71fd1418f73df5e724c99c818053b1151a
|
File details
Details for the file antecedent-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1209eaab9c5e797c90271eb7d8c34a1ac946f7a17b93d7444d805fd6a049d82f
|
|
| MD5 |
69acf308d39eaba30416d87601cf2cdf
|
|
| BLAKE2b-256 |
735506021d15975b6e3c066aa27805494dffdf7463c474bfa51c7a6b1219c6bc
|
File details
Details for the file antecedent-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41cd82a77a1fc740b8409620c2f49e734d284405a65e312acc614300347470dd
|
|
| MD5 |
5d218c1aad9cbf8fbc97ec1264fa7d1f
|
|
| BLAKE2b-256 |
4c73dd984f3029c5e2e91178c783e81de63913ea27f583fd1f1c05261925251c
|
File details
Details for the file antecedent-0.3.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6531fe4973f86420d73146c495ad77762cda40507c29c94a92da38c7bbe2a328
|
|
| MD5 |
a00d6bbcdec5d553a69d2a78e186712b
|
|
| BLAKE2b-256 |
f61c71b54b1d8627b6a763c49fa9061db4f6a61604fd0b200e0886738bb040a5
|
File details
Details for the file antecedent-0.3.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0fb08bc984fadc1e3666224afc0db25c53ad34207bb406805265580bd5bbfa6
|
|
| MD5 |
b23f60a5dc26973c10c1b0cc7de2cfa0
|
|
| BLAKE2b-256 |
273b33f21ca6f9b33ec48f982baecdcabb421d260d10599401d39c5237492c10
|
File details
Details for the file antecedent-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48ce7d2a42d08cb78244db6cd6ca14c40aeb4e3bdc47349713491f51112d2c3d
|
|
| MD5 |
bc560c442e4e84640717ec604f54d9f8
|
|
| BLAKE2b-256 |
a673098b5cc8b1515f5cb849141194240af67d6f57aae34e68ec6af953025c40
|
File details
Details for the file antecedent-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de4d96ea7bbd7d9b6c2049d019a50074a935d86dec3a5775d47d1956a195071
|
|
| MD5 |
a92321ff280a7ff2decf1d1e56c4f128
|
|
| BLAKE2b-256 |
414f1c361697f611f0535052895f21aabf71624d164e26c8d9c955b9f4704c17
|
File details
Details for the file antecedent-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a2a9b059cbd8c6d6ccaecc6a22be097f79bfc4023e588b79a010ba627ff75a2
|
|
| MD5 |
ae23af209052962a35e9ca69e5cbcb66
|
|
| BLAKE2b-256 |
964e89cb689ef5cae8dfbddd39650e4323c579bd48c98214b50f5d19c0cace96
|
File details
Details for the file antecedent-0.3.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679296e4919344b2020ae2dc879e6b070b6b21eb9575a6988694fe84ad136097
|
|
| MD5 |
0529e705aa9ec26542f3072e8eb5dfee
|
|
| BLAKE2b-256 |
b154643c2f3579e2b2a783dba4029bb0d0b96d167f4c644e8de0edf86fa30cc2
|
File details
Details for the file antecedent-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
334e88ece0a0095a3875736befb938f34aab65b58102b9c8e14066ff4df711ea
|
|
| MD5 |
2ef1c6ed313abfbce69dab8d109a7cd8
|
|
| BLAKE2b-256 |
0106c6e1f60069c7a419dcf0280f0ae4f4ff72fa8aef60fc0cf3e1b9a72986b9
|
File details
Details for the file antecedent-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b87324f156b07c024476812cd95b4eb7fe31c1df8e7cc9b72c04cfcc698053f
|
|
| MD5 |
b9ee44d93e5fb39b6f874b3ee058b8b3
|
|
| BLAKE2b-256 |
c1b3866fb37d72850cac88abbc9d4063bf16e985c887054fa9ec54f8a80a69c1
|
File details
Details for the file antecedent-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83186ebee01725c102e48f6cd2e1bb9f5b3c5c9eb82f23a8b1a92cbc1fe90b64
|
|
| MD5 |
1624ff28083fcd01039bc327166d78c9
|
|
| BLAKE2b-256 |
08a36fe67e8ad8008913fe7171651139ff645cec2356f7164d8a2e0eeb605dc9
|
File details
Details for the file antecedent-0.3.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d36be86cdc5b6ac2469a8771322171714bbcbea600deca896865e08bbac1b2d
|
|
| MD5 |
8eb2f6769d172ce9b1eb14c025fd5780
|
|
| BLAKE2b-256 |
2a0f01932d56cd70ffd070b30bb55db6c9d1b978d82682297e7d1e0eeaeeb3ae
|
File details
Details for the file antecedent-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d1ca16baf292e79cfc91772fb296f1686478cc9f49a7b23d741cb20ea4c961d
|
|
| MD5 |
8e1c7cc40aa95bc1b46db80efab5d3e6
|
|
| BLAKE2b-256 |
f53b1683dd751635caaf3f4dbf483ec668b81b993e9cf10d016c2b26e7c3b151
|
File details
Details for the file antecedent-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
604ffd174f0a8484849a9f7adfa27c35e2e3bc852f3b38c93534bd195e1fb2b2
|
|
| MD5 |
959ff36c5fe370f5931bd3c5669bd909
|
|
| BLAKE2b-256 |
7e51de7edf6c5314ace3a140f93ec841559385801ba9df3370560530b5f5567b
|
File details
Details for the file antecedent-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: antecedent-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
758a14633820c56b0d675a2ecda851f8514df0c67d14465e655d507b1bf06837
|
|
| MD5 |
81df12932bb8bffc3bf1ee9fc0e65497
|
|
| BLAKE2b-256 |
c1c34e685872f7541b719135f1e6190cf61be4fc3fa4c3af0c95bf8a5776f972
|