causallib
A Python package for flexible and modular causal inference modeling
What it is and what it does
Causallib is a Python library for estimating causal effects from observational (non-experimental) data. It provides a suite of causal inference methods—weight-based models like IPW and direct outcome models like Standardization—all under a unified fit-and-predict interface. You supply your own machine learning model to handle internal prediction tasks, then use causallib's methods to estimate potential outcomes and treatment effects.
The package is designed around the potential outcomes framework: it separates potential-outcome prediction from effect estimation, which allows flexible specification of stratified effects and supports multi-treatment scenarios. It includes an evaluation suite that reinterprets standard ML diagnostics from a causal perspective, helping identify when internal models underperform. The out-of-bag fit-and-predict workflow supports honest effect estimation by training on one set of examples and evaluating on another.
Use it for:
- Estimate average treatment effect (ATE) or treatment effect on the treated (ATT) from observational health or social science data.
- Build conditional average treatment effect (CATE) models to predict individual-level causal effects using direct outcome methods.
- Diagnose and debug causal models by applying ML evaluation metrics through a causal lens to identify model misspecification.
- Chain causal inference with preprocessing pipelines to filter rows and select confounders before effect estimation.
- Compare multiple causal inference strategies (IPW vs. Standardization) on the same data under a unified API.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Causallib estimates causal effects from observational data using a modular, scikit-learn-inspired API that supports pluggable machine learning models for flexible causal inference.
Yes. Causallib is actively maintained, has no known vulnerabilities, and offers a well-designed, modular approach to causal inference that will appeal to researchers and practitioners working with observational data. The fit-and-predict API and support for arbitrary ML models make it flexible and integrable into existing workflows. Install it if you need to estimate treatment effects from non-experimental data.
Install
causallib on PyPI
pip
pip install causallibuv
uv add causallibpoetry
poetry add causallibInstalling causallib
Before you install
Low friction install with a pure-Python wheel and a stable, actively maintained codebase. The package depends on common scientific libraries (pandas, scipy, numpy, matplotlib, statsmodels, networkx, dataclasses) that are widely available.
License in practice
Apache License 2.0 is permissive, allowing commercial and private use with minimal restrictions; you must include a copy of the license and state significant changes, but there is no copyleft requirement.
Quickstart
pip install causallib
from causallib.estimation import IPW
from causallib.datasets import load_nhefs
data = load_nhefs()
ipw = IPW(model)
ipw.fit(data.X, data.a)
potential_outcomes = ipw.estimate_population_outcome(data.X, data.a, data.y)
effect = ipw.estimate_effect(potential_outcomes[1], potential_outcomes[0])
Requires a machine learning model with sklearn-like fit-predict API; some causal models may require predict_proba implementation.
Verify before relying
- Whether the package supports Python versions beyond 3.9 (classifiers list 3.6–3.9 but requires_python is unspecified)
- Whether all causal models require predict_proba or only some (documentation mentions 'some models might require' it)
- Performance characteristics and scalability limits for large datasets
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — pandas, scipy, statsmodels, networkx, numpy, scikit-learn, matplotlib, dataclasses |
| Maintenance | actively maintained — 495 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,654,498/month — #2,957 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: causallib-0.10.0-py3-none-any.whl
Keywords: causal, inference, effect, estimation, causality
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
causalmlCausalml estimates the causal impact of…
permissive · top 15,000 on PyPI
dowhyDoWhy is a Python library for causal inference…
permissive · top 15,000 on PyPI
psmpyPsmPy implements propensity score matching for…
permissive · top 5,000 on PyPI
empirical-calibrationComputes empirical calibration weights to…
permissive · top 15,000 on PyPI
econmlEconML estimates heterogeneous treatment…
permissive · top 15,000 on PyPI
pgmpypgmpy provides data structures and algorithms…
unclear · top 5,000 on PyPI
cemImplements Coarsened Exact Matching (CEM), a…
unclear · top 5,000 on PyPI
pyfixestPyFixest performs fast high-dimensional fixed…
permissive · top 15,000 on PyPI