Skip to main content

A Python toolkit for causal inference and experimentation

Project description

Causalis

Python PyPI Downloads License: MIT Code quality

Causalis logo

Robust causal inference for experiments and observational studies in Python, organized around scenarios (e.g., Classic RCT, CUPED, Unconfoundedness) with a consistent fit() → estimate() workflow.

Why Causalis?

Causalis focuses on:

  • Scenario-first workflows (you pick the study design; Causalis provides best-practice defaults).
  • Guardrails and diagnostics (e.g., SRM checks, balance checks).
  • Typed data contracts (CausalData) to fail fast on schema issues.

Installation

Recommended

pip install causalis

Releasing

Production releases are created from annotated Git tags on main. The tag drives the package version through setuptools-scm, then GitHub Actions builds, checks, publishes to PyPI with Trusted Publishing, and creates the matching GitHub Release.

git checkout main
git pull --ff-only origin main
python3 -m pytest

git tag -a v0.5.1 -m "Release v0.5.1"
git push origin v0.5.1

Do not edit a version string by hand or upload release artifacts manually. Configure the PyPI trusted publisher for causalis-causalcraft/Causalis, workflow release.yml, and environment pypi.

Quickstart: Classic RCT (difference in means + inference)

from causalis.dgp import generate_classic_rct_26
from causalis.scenarios.classic_rct import DiffInMeans, check_srm

# Synthetic RCT data as a validated CausalData object
data = generate_classic_rct_26(seed=42, return_causal_data=True)

# Optional: Sample Ratio Mismatch check
srm = check_srm(data, target_allocation={0: 0.5, 1: 0.5}, alpha=1e-3)
print("SRM detected?", srm.is_srm, "p=", srm.p_value, "chi2=", srm.chi2)

# Estimate treatment effect with t-test inference (or bootstrap / conversion_ztest)
result = DiffInMeans().fit(data).estimate(method="ttest", alpha=0.05)
result.summary()

Quickstart: Observational study (Unconfoundedness / DML IRM)

from causalis.scenarios.unconfoundedness.dgp import generate_obs_hte_26
from causalis.scenarios.unconfoundedness import IRM
from causalis.data_contracts import CausalData

causaldata = generate_obs_hte_26(return_causal_data=True, include_oracle=False)

from causalis.scenarios.unconfoundedness import IRM

model = IRM().fit(causaldata)
result = model.estimate(score='ATTE')
result.summary()

Pick your scenario

Classic RCT: randomized assignment (no pre-period metric).

CUPED: randomized assignment with pre-period metric for variance reduction.

Unconfoundedness: observational study adjusting for measured confounders (DML IRM).

See scenario notebooks: https://causalis.causalcraft.com/explore-scenarios

Responsible use / limitations

Causal estimates require identification assumptions (e.g., randomization or unconfoundedness + overlap). Causalis can help with diagnostics, but it cannot guarantee assumptions hold in your data.

Contributing

Contributions are welcome—bug reports, docs fixes, notebooks, and new estimators. Please read CONTRIBUTING.md and follow the Code of Conduct.

Getting help

Questions: GitHub Discussions

Bugs: GitHub Issues (include minimal repro + versions)

License

MIT (see LICENSE).

Acknowledgements

https://github.com/DoubleML/doubleml-for-py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causalis-0.3.2.tar.gz (11.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

causalis-0.3.2-py3-none-any.whl (345.6 kB view details)

Uploaded Python 3

File details

Details for the file causalis-0.3.2.tar.gz.

File metadata

  • Download URL: causalis-0.3.2.tar.gz
  • Upload date:
  • Size: 11.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for causalis-0.3.2.tar.gz
Algorithm Hash digest
SHA256 bafa3fdae580ff454313730fa9206272f8e41ec2b49d226641c285fc0aabe729
MD5 ef7560fcb1bbdf9873b8b10424950e07
BLAKE2b-256 c208265c8cb9a9ecf1fe570c99ad1106a9455befdf719bc2c2e7f154b467aa8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for causalis-0.3.2.tar.gz:

Publisher: release.yml on causalis-causalcraft/Causalis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file causalis-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: causalis-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 345.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for causalis-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 446d34f4337636b635a1686eab6c2a5c304bcd81fa0ce6327ec4d5c8ae622c15
MD5 a476232ee18a515d0f60e4e4a188971f
BLAKE2b-256 e3979b308da5087a06d341ea806113eae28fa5fbc9fbaa688d138512ca3a9a20

See more details on using hashes here.

Provenance

The following attestation bundles were made for causalis-0.3.2-py3-none-any.whl:

Publisher: release.yml on causalis-causalcraft/Causalis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page