Antecedent for Python
Antecedent is a compiler and runtime for causal science. You declare a causal question, a causal graph or study design, and the data. Antecedent checks whether those declarations identify the quantity you asked for, compiles an analysis you can inspect before anything is fitted, and executes a supported route. Every answer carries its identification, support, uncertainty, calibration status and the methods it rests on. A question the declarations cannot answer returns a typed refusal that names what is missing.
This is the Python package. It exposes the same causal contract as the Rust crate antecedent, in Python's idiom. Documentation: https://antecedent.readthedocs.io/.
Install
python -m pip install antecedent
Python 3.11 or later. Wheels cover CPython 3.11–3.14 on Linux (x86_64 and aarch64), macOS arm64 and Windows x86_64; other platforms need a source build. NumPy and Pydantic are installed as dependencies.
A first analysis
The example simulates a randomized treatment whose effect on the outcome is two units, so the estimate can be checked against a known truth. It prepares the analysis, inspects the plan, estimates the effect, repeats the analysis on changed data, and exports the result.
import numpy as np
import antecedent as ant
rng = np.random.default_rng(17)
z = rng.normal(size=160)
treatment = rng.binomial(1, 0.5, size=160).astype(float)
data = {
"treatment": treatment,
"outcome": 2 * treatment + z + rng.normal(size=160),
"z": z,
}
graph = [("treatment", "outcome"), ("z", "outcome")]
query = ant.AverageEffect("treatment", "outcome")
# Prepare: declare the question and check what it needs. Nothing is fitted yet.
study = ant.prepare(
ant.data.table(data), graph=graph, query=query,
inference=ant.Frequentist(bootstrap=25),
execution=ant.Execution(seed=19),
)
# Inspect the compiled analysis before running it.
print(study.inspect())
# Execute, then read the answer with its uncertainty and identification.
result = ant.estimate(study)
print("Answer:", result.answer.kind, result.answer.value)
print("Uncertainty:", result.uncertainty.summary)
report = result.inspect().to_dict()
print("Identification:", report["identification"]["summary"])
for citation in result.citations(): # the published methods behind this answer
print("Method:", citation.reference)
assert abs(result.answer.value - 2) < 0.5 # the simulated truth is 2
# Rebind: a new branch on changed observations. The earlier result is unchanged.
new_data = {**data, "outcome": data["outcome"] + treatment}
updated_study = ant.rebind(study, data=new_data)
updated = ant.estimate(updated_study)
print("Updated effect:", updated.answer.value) # one unit larger
# Export the result and load it with an explicit expectation.
artifact = result.export()
loaded = ant.load(artifact, expected=artifact.expectation)
print("Artifact acceptance:", loaded.acceptance.status)
The estimate lands near two, and the updated branch is one unit larger. The bootstrap budget is small so the example runs quickly; read result.inspect().calibration before relying on interval coverage. Your first analysis walks through each step, and how to read a result explains each field.
How the pieces fit
- Lifecycle.
ant.prepare(...)returns an immutable study;ant.estimate(study)returns anOutcome;ant.analyze(...)is the one-shot form.ant.rebind(study, data=...)andant.reconfigure(study, ...)return new studies and change nothing earlier.result.export()produces an artifact thatant.load(artifact, expected=artifact.expectation)reads back. - Settings. Seed, threads, cancellation and resource limits belong to
ant.Execution; the bootstrap count or posterior draws belong toant.Frequentist(...)/ant.Bayesian(...). - Refusals. A valid question the declared structure cannot answer returns an
Outcomewith a typedrefusal(addon_refusal="describe"for a labelled associational description beside it); invalid arguments and operational failures raise. - Support. A route runs when it has provenance and an independent scientific check; otherwise it returns a
not_supportedrefusal that names the missing evidence. The support matrix lists the supported units; how Antecedent checks its scientific methods explains the model. - Calibration. Every reported interval carries its calibration status (
calibrated,outside_measured_scope,measured_below_nominalornot_measured), which annotates the interval and, at run time, never decides whether a route runs. - Citations. Every result names the provenance records behind the route it executed, so its citations travel with it:
result.citations()for one result,antecedent.citations.bibliography(...)for a whole study. See how to cite the methods behind a study.
The root namespace has an explicit exported-name contract; see the naming dictionary.
Beyond one effect
| Task | Where |
|---|---|
| Large adjustment problems | Configured DML, DR-Learner and causal-forest estimators. The standard wheel includes the CPU-native antecedent.learners.NeuralNet nuisance learner; no separate Python extra is needed. These estimators use held-out nuisance predictions and disclose their learner, folds, overlap and uncertainty limitations; they do not make a CATE interval appear where none was estimated. |
| Transport to another population | antecedent.transport.Transport, with explicit target and evidence information. Evidence availability is not inferred from a column name or a selection label. |
| Design-family studies | antecedent.experiment, antecedent.policy, antecedent.quasi, antecedent.survival and antecedent.regimes prepare and analyze as retained studies. On the experiment, policy, regime and interference queries, row-aligned inputs may be named by a data column; prepare resolves those names and freezes the design. Their interval claims are rows of the design-family support matrix, separate from the geometric matrix. |
| Main effects and interaction of a 2×2 factorial | antecedent.factorial.estimate, a separate point utility, not a retained study. |
Documentation
- Your first analysis and how to read a result
- Supported analyses: choose a question and an estimator
- Python API and Python workflow options
- Examples and the tutorials listed on the documentation home
- Upgrading from 2.4? The migration guide gives every old and new form.
License
MIT OR Apache-2.0.
Metadata
Release files for antecedent 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 1.2 GB
Release files / antecedent-3.0.0-cp314-cp314-win_amd64.whl
| Download URL | antecedent-3.0.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 77.1 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1dbcb091c3c55ec414e5e151b3299525b6590afa1fa28b7774bed59c619131a9
|
|
BLAKE2b-256 checksum How to use checksums |
eacad9152562a207ab1ce3a132ed4e320a6dc5e049f79c26e42fdb3d5cc3b28b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | antecedent-3.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 77.6 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
59d0b4f47f5088ec3005934b1cdf4b35a7c2d86b9981dd9967e172611dfa43b4
|
|
BLAKE2b-256 checksum How to use checksums |
0635ef1e1e068eba3b72c4e02ad87539cd03717e186480a5f56e5ee9f03c0640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | antecedent-3.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 76.9 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
b62719c316e784a729152637f64c5271d85f6c2dbbc9497c94197ee73ad2244d
|
|
BLAKE2b-256 checksum How to use checksums |
f8a8c436b4b42940b0ad0bf5d81504ae3ea93e885657e54cac5cb665d00f8765
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | antecedent-3.0.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 70.1 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c38b233912c9f47b706fda9ccae8bec3b5fc7122b20b50874de53463345f33ac
|
|
BLAKE2b-256 checksum How to use checksums |
8a0739ee2a2b51b09e5b2289f705befecac81a27de508a9b3028594de208c98a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp313-cp313-win_amd64.whl
| Download URL | antecedent-3.0.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 77.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
627c03faa539bbaa443aed72133ba717d61174fc31e9431d3b3a9ed04f7cc4ce
|
|
BLAKE2b-256 checksum How to use checksums |
6161537baf4d00b4a96e93e166b0cf13157ec0278843b521a5567935c04fce0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | antecedent-3.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 77.6 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
8190e64c935f2e7a1afb8078631e55eed312035c6a227e3c7527b87cf6f73922
|
|
BLAKE2b-256 checksum How to use checksums |
6b237d830ab122a66be7a538bf862b9fea3052e57168dc47d1b08247738a38b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | antecedent-3.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 76.9 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
9215efc471356308ebc781c082bcc634d081038cdc11270209e71600e42995b0
|
|
BLAKE2b-256 checksum How to use checksums |
af5ff0c04a5d6c48548297bfee345415aca14fb659ca155232f3b858fe2783df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | antecedent-3.0.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 70.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
af48227fe01546a0a35de2ebb1d43475033a86e04bd56498920bf847536b19aa
|
|
BLAKE2b-256 checksum How to use checksums |
bcfa088e8c5b9ad196ededb8d06d1142a24a285a93fd7979573a5a152d4e6fdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp312-cp312-win_amd64.whl
| Download URL | antecedent-3.0.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 77.1 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
eda455941f39817c0a285efa766165277b746f9e1d668495a84156da96fbfd6c
|
|
BLAKE2b-256 checksum How to use checksums |
eb9d38325edf741bd57867c68e21f8db59b86ea1a4527fe7c546b47b14bee878
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | antecedent-3.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 77.6 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5466ce2358c62d97f3b6152047fa89eca5111cd69e569e755d1ec3e692284551
|
|
BLAKE2b-256 checksum How to use checksums |
0e1083edade1e854a1ff2589b06cae65f9e98481d67313c7df777b9b65f3054a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | antecedent-3.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 76.9 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
7fff01732328c5ecf7e635a01d80de6f1e7f3f6d7f856afb98db1214ec2e68bc
|
|
BLAKE2b-256 checksum How to use checksums |
cb634f7ca05271f6a317e1c65a0acee89cfa4f36b88c2b7d4b49d53079fac874
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | antecedent-3.0.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 70.1 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
13a22e9cd59b187eeccfb6236ecc4c42c301db9ffd9b1e946859cdea8bc630a7
|
|
BLAKE2b-256 checksum How to use checksums |
916cfa98bbf90f2b7b4a6906c9569061bdf1c7312b11b9ba4e127a7fb9bd747e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp311-cp311-win_amd64.whl
| Download URL | antecedent-3.0.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 77.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9de3c0a490c959758c3da9885acc34da49d8ffbd8381aa48252309b768892c29
|
|
BLAKE2b-256 checksum How to use checksums |
5d835793803868a92f1eb72c696410abda726d8cc95b2dfb535426bc8077b529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | antecedent-3.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 77.7 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e1911fc264f680c50e8080019609f1dd0140883bf1b2a14e320d625e2ed46e83
|
|
BLAKE2b-256 checksum How to use checksums |
61ec5f74e8f5921de272c799c5ffe0b3c98632a9f5ee64074b9b344e5b40f5a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | antecedent-3.0.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 76.9 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
6722aa4b65dbb91105775cafdbbe57fc3d83d6e3ee32b788729e13156504efb6
|
|
BLAKE2b-256 checksum How to use checksums |
d94759f3bc2aaa43e1cc4d6597253c30c28aa234b270722070f14fc35b349a50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / antecedent-3.0.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | antecedent-3.0.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 70.3 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
44916933792c1c3622b25a89ab9dce2c0dba79a0650d7232e923c661f881b76b
|
|
BLAKE2b-256 checksum How to use checksums |
bc284afccc1d1e3f468662cda050e19b2244d85d1fb725289f221dd3e266ef2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for antecedent 3.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.