EconML is a Python package for estimating heterogeneous treatment effects from observational data via machine learning. This package was designed and built as part of the ALICE project at Microsoft Research with the goal to combine state-of-the-art machine learning techniques with econometrics to bring automation to complex causal inference problems. The promise of EconML:
- Implement recent techniques in the literature at the intersection of econometrics and machine learning
- Maintain flexibility in modeling the effect heterogeneity (via techniques such as random forests, boosting, lasso and neural nets), while preserving the causal interpretation of the learned model and often offering valid confidence intervals
- Use a unified API
- Build on standard Python packages for Machine Learning and Data Analysis
One of the biggest promises of machine learning is to automate decision making in a multitude of domains. At the core of many data-driven personalized decision scenarios is the estimation of heterogeneous treatment effects: what is the causal effect of an intervention on an outcome of interest for a sample with a particular set of features? In a nutshell, this toolkit is designed to measure the causal effect of some treatment variable(s) T
on an outcome
variable Y
, controlling for a set of features X, W
and how does that effect vary as a function of X
. The methods implemented are applicable even with observational (non-experimental or historical) datasets. For the estimation results to have a causal interpretation, some methods assume no unobserved confounders (i.e. there is no unobserved variable not included in X, W
that simultaneously has an effect on both T
and Y
), while others assume access to an instrument Z
(i.e. an observed variable Z
that has an effect on the treatment T
but no direct effect on the outcome Y
). Most methods provide confidence intervals and inference results.
For detailed information about the package, consult the documentation at https://econml.azurewebsites.net/.
For information on use cases and background material on causal inference and heterogeneous treatment effects see our webpage at https://www.microsoft.com/en-us/research/project/econml/
<details> <summary><strong><em>Table of Contents</em></strong></summary>- News
- Getting Started
- For Developers
- Blogs and Publications
- Citation
- Contributing and Feedback
- Community
- References
News
If you'd like to contribute to this project, see the Help Wanted section below.
July 3, 2024: Release v0.15.1, see release notes here
<details><summary>Previous releases</summary>February 12, 2024: Release v0.15.0, see release notes here
November 11, 2023: Release v0.15.0b1, see release notes here
May 19, 2023: Release v0.14.1, see release notes here
November 16, 2022: Release v0.14.0, see release notes here
June 17, 2022: Release v0.13.1, see release notes here
January 31, 2022: Release v0.13.0, see release notes here
August 13, 2021: Release v0.12.0, see release notes here
August 5, 2021: Release v0.12.0b6, see release notes here
August 3, 2021: Release v0.12.0b5, see release notes here
July 9, 2021: Release v0.12.0b4, see release notes here
June 25, 2021: Release v0.12.0b3, see release notes here
June 18, 2021: Release v0.12.0b2, see release notes here
June 7, 2021: Release v0.12.0b1, see release notes here
May 18, 2021: Release v0.11.1, see release notes here
May 8, 2021: Release v0.11.0, see release notes here
March 22, 2021: Release v0.10.0, see release notes here
March 11, 2021: Release v0.9.2, see release notes here
March 3, 2021: Release v0.9.1, see release notes here
February 20, 2021: Release v0.9.0, see release notes here
January 20, 2021: Release v0.9.0b1, see release notes here
November 20, 2020: Release v0.8.1, see release notes here
November 18, 2020: Release v0.8.0, see release notes here
September 4, 2020: Release v0.8.0b1, see release notes here
March 6, 2020: Release v0.7.0, see release notes here
February 18, 2020: Release v0.7.0b1, see release notes here
January 10, 2020: Release v0.6.1, see release notes here
December 6, 2019: Release v0.6, see release notes here
November 21, 2019: Release v0.5, see release notes here.
June 3, 2019: Release v0.4, see release notes here.
May 3, 2019: Release v0.3, see release notes here.
April 10, 2019: Release v0.2, see release notes here.
March 6, 2019: Release v0.1, welcome to have a try and provide feedback.
</details>Getting Started
Installation
Install the latest release from PyPI:
pip install econml
To install from source, see For Developers section below.
Usage Examples
Estimation Methods
<details> <summary>Double Machine Learning (aka RLearner) (click to expand)</summary>- Linear final stage
from econml.dml import LinearDML from sklearn.linear_model import LassoCV from econml.inference import BootstrapInference est = LinearDML(model_y=LassoCV(), model_t=LassoCV()) ### Estimate with OLS confidence intervals est.fit(Y, T, X=X, W=W) # W -> high-dimensional confounders, X -> features treatment_effects = est.effect(X_test) lb, ub = est.effect_interval(X_test, alpha=0.05) # OLS confidence intervals ### Estimate with bootstrap confidence intervals est.fit(Y, T, X=X, W=W, inference='bootstrap') # with default bootstrap parameters est.fit(Y, T, X=X, W=W, inference=BootstrapInference(n_bootstrap_samples=100)) # or customized lb, ub = est.effect_interval(X_test, alpha=0.05) # Bootstrap confidence intervals
- Sparse linear final stage
from econml.dml import SparseLinearDML from sklearn.linear_model import LassoCV est = SparseLinearDML(model_y=LassoCV(), model_t=LassoCV()) est.fit(Y, T, X=X, W=W) # X -> high dimensional features treatment_effects = est.effect(X_test) lb, ub = est.effect_interval(X_test, alpha=0.05) # Confidence intervals via debiased lasso
- Generic Machine Learning last stage
</details> <details> <summary>Dynamic Double Machine Learning (click to expand)</summary>from econml.dml import NonParamDML from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier est = NonParamDML(model_y=RandomForestRegressor(), model_t=RandomForestClassifier(), model_final=RandomForestRegressor(), discrete_treatment=True) est.fit(Y, T, X=X, W=W) treatment_effects = est.effect(X_test)
</details> <details> <summary>Causal Forests (click to expand)</summary>from econml.panel.dml import DynamicDML # Use defaults est = DynamicDML() # Or specify hyperparameters est = DynamicDML(model_y=LassoCV(cv=3), model_t=LassoCV(cv=3), cv=3) est.fit(Y, T, X=X, W=None, groups=groups, inference="auto") # Effects treatment_effects = est.effect(X_test) # Confidence intervals lb, ub = est.effect_interval(X_test, alpha=0.05)
</details> <details> <summary>Orthogonal Random Forests (click to expand)</summary>from econml.dml import CausalForestDML from sklearn.linear_model import LassoCV # Use defaults est = CausalForestDML() # Or specify hyperparameters est = CausalForestDML(criterion='het', n_estimators=500, min_samples_leaf=10, max_depth=10, max_samples=0.5, discrete_treatment=False, model_t=LassoCV(), model_y=LassoCV()) est.fit(Y, T, X=X, W=W) treatment_effects = est.effect(X_test) # Confidence intervals via Bootstrap-of-Little-Bags for forests lb, ub = est.effect_interval(X_test, alpha=0.05)
</details> <details> <summary>Meta-Learners (click to expand)</summary>from econml.orf import DMLOrthoForest, DROrthoForest from econml.sklearn_extensions.linear_model import WeightedLasso, WeightedLassoCV # Use defaults est = DMLOrthoForest() est = DROrthoForest() # Or specify hyperparameters est = DMLOrthoForest(n_trees=500, min_leaf_size=10, max_depth=10, subsample_ratio=0.7, lambda_reg=0.01, discrete_treatment=False, model_T=WeightedLasso(alpha=0.01), model_Y=WeightedLasso(alpha=0.01), model_T_final=WeightedLassoCV(cv=3), model_Y_final=WeightedLassoCV(cv=3)) est.fit(Y, T, X=X, W=W) treatment_effects = est.effect(X_test) # Confidence intervals via Bootstrap-of-Little-Bags for forests lb, ub = est.effect_interval(X_test, alpha=0.05)
- XLearner
from econml.metalearners import XLearner from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor est = XLearner(models=GradientBoostingRegressor(), propensity_model=GradientBoostingClassifier(), cate_models=GradientBoostingRegressor()) est.fit(Y, T, X=np.hstack([X, W])) treatment_effects = est.effect(np.hstack([X_test, W_test])) # Fit with bootstrap confidence interval construction enabled est.fit(Y, T, X=np.hstack([X, W]), inference='bootstrap') treatment_effects = est.effect(np.hstack([X_test, W_test])) lb, ub = est.effect_interval(np.hstack([X_test, W_test]), alpha=0.05) # Bootstrap CIs
- SLearner
from econml.metalearners import SLearner from sklearn.ensemble import GradientBoostingRegressor est = SLearner(overall_model=GradientBoostingRegressor()) est.fit(Y, T, X=np.hstack([X, W])) treatment_effects = est.effect(np.hstack([X_test, W_test]))
- TLearner
</details> <details> <summary>Doubly Robust Learners (click to expand) </summary>from econml.metalearners import TLearner from sklearn.ensemble import GradientBoostingRegressor est = TLearner(models=GradientBoostingRegressor()) est.fit(Y, T, X=np.hstack([X, W])) treatment_effects = est.effect(np.hstack([X_test, W_test]))
- Linear final stage
from econml.dr import LinearDRLearner from sklearn.ensemble import GradientBoostingRegressor, GradientBoostingClassifier est = LinearDRLearner(model_propensity=GradientBoostingClassifier(), model_regression=GradientBoostingRegressor()) est.fit(Y, T, X=X, W=W) treatment_effects = est.effect(X_test) lb, ub = est.effect_interval(X_test, alpha=0.05)
- Sparse linear final stage
from econml.dr import SparseLinearDRLearner from sklearn.ensemble import GradientBoostingRegressor, GradientBoostingClassifier est = SparseLinearDRLearner(model_propensity=GradientBoostingClassifier(), model_regression=GradientBoostingRegressor()) est.fit(Y, T, X=X, W=W) treatment_effects = est.effect(X_test) lb, ub = est.effect_interval(X_test, alpha=0.05)
- Nonparametric final stage
from econml.dr import ForestDRLearner from sklearn.ensemble import
编辑推荐精选


Manus
全面超越基准的 AI Agent助手
Manus 是一款通用人工智能代理平台,能够将您的创意和想法迅速转化为实际成果。无论是定制旅行规划、深入的数据分析 ,还是教育支持与商业决策,Manus 都能高效整合信息,提供精准解决方案。它以直观的交互体验和领先的技术,为用户开启了一个智慧驱动、轻松高效的新时代,让每个灵感都能得到完美落地。


飞书知识问答
飞书官方推出的AI知识库 上传word pdf即可部署AI私有知识库
基于DeepSeek R1大模型构建的知识管理系统,支持PDF、Word、PPT等常见文档格式解析,实现云端与本地数据的双向同步。系统具备实时网络检索能力,可自动关联外部信息源,通过语义理解技术处理结构化与非结构化数据。免费版本提供基础知识库搭建功能,适用于企业文档管理和个人学习资料整理场景。


Trae
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

酷表ChatExcel
大模型驱动的Excel数据处理工具
基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


DeepEP
DeepSeek开源的专家并行通信优化框架
DeepEP是一个专为大规模分布式计算设计的通信库,重点解决专家并行模式中的通信瓶颈问题。其核心架构采用分层拓扑感知技术,能够自动识别节点间物理连接关系,优化数据传输路径。通过实现动态路由选择与负载均衡机制,系统在千卡级计算集群中维持稳定的低延迟特性,同时兼容主流深度学习框架的通信接口。


DeepSeek
全球领先开源大模型,高效智能助手
DeepSeek是一家幻方量化创办的专注于通用人工智能的中国科技公司,主攻大模型研发与应用。DeepSeek-R1是开源的推理模型,擅长处理复杂任务且可免费商用。


KnowS
AI医学搜索引擎 整合4000万+实时更新的全球医学文献
医学领域专用搜索引擎整合4000万+实时更新的全球医学文献,通过自主研发AI模型实现精准知识检索。系统每日更新指南、中英文文献及会议资料,搜索准确率较传统工具提升80%,同时将大模型幻觉率控制在8%以下。支持临床建议生成、文献深度解析、学术报告制作等全流程科研辅助,典型用户反馈显示每周可节省医疗工作者70%时间。


Windsurf Wave 3
Windsurf Editor推出第三次重大更新Wave 3
新增模型上下文协议支持与智能编辑功能。本次更新包含五项核心改进:支持接入MCP协议扩展工具生态,Tab键智能跳转提升编码效率,Turbo模式实现自动化终端操作,图片拖拽功能优化多模态交互,以及面向付费用户的个性化图标定制。系统同步集成DeepSeek、Gemini等新模型,并通过信用点数机制实现差异化的资源调配。


腾讯元宝
腾讯自研的混元大模型AI助手
腾讯元宝是腾讯基于自研的混元大模型推出的一款多功能AI应用,旨在通过人工智能技术提升用户在写作、绘画、翻译、编程、搜索、阅读总结等多个领域的工作与生活效率。


Grok3
埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型
Grok3 是由埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型,常被马斯克称为“地球上最聪明的 AI”。它不仅是在前代产品 Grok 1 和 Grok 2 基础上的一次飞跃,还在多个关键技术上实现了创新突破。
推荐工具精选
AI云服务特惠
懂AI专属折扣关注微信公众号
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号