skillfed

causallib

A Python package for flexible and modular causal inference modeling

causallib v0.10.0 2.7M downloads/30d#2,957 on PyPI833
Permissive license Apache License 2.0 Active released

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 causallib

uv

uv add causallib

poetry

poetry add causallib

Installing 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

Development Status :: 4 - BetaIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering

Tags

causal inference observational datatreatment effect estimationcausal effect modelingcounterfactual outcome predictioncausal inference pythontreatment effect analysiscausal models machine learning
causal-inferenceobservational-datatreatment-effects

More Scientific/Engineering packages