--- id: causallib version: "0.10.0" license: Apache License 2.0 license_treatment: permissive maintenance: active --- # causallib — A Python package for flexible and modular causal inference modeling License: permissive · Maintenance: active · Downloads: 2.7M/mo ## 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 above — 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 pip install causallib uv add causallib 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: unspecified - Install friction: low - Maintenance: active - Downloads: 2.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags causal inference observational data, treatment effect estimation, causal effect modeling, counterfactual outcome prediction, causal inference python, treatment effect analysis, causal models machine learning, causal-inference, observational-data, treatment-effects [View on SkillFed](https://skillfed.io/packages/causallib) · [View on PyPI](https://pypi.org/project/causallib/)