Registry / ai-ml / econml

econml

JSON →
library0.17.0pypypi✓ verified 27d ago

EconML is a Python library for estimating Conditional Average Treatment Effects (CATEs) from observational or experimental data. It provides a suite of advanced machine learning methods, including Double Machine Learning (DML) and Causal Forests, to infer causal relationships and individual-level treatment effects. The current version is 0.16.0, and it maintains an active development pace with major updates and bugfix releases every few months.

pip install econml
INSTALL
IMPORT
SIG · ECONML
E
econml
ai-mlpythonv0.17.0
Install
22.2s avg
Import
5176ms
Disk
657MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.17.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
build_error
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 22.2s · import 5.176s · 651MB
657MB installed
● package 657MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CausalForestDML
✓ from econml.dml import CausalForestDML
✗ from econml.dr import CausalForestDML
CausalForestDML, like other DML estimators, resides in `econml.dml`.
LinearDML
✓ from econml.dml import LinearDML
LinearDML is part of the Double Machine Learning (DML) module.
DynamicDML
✓ from econml.panel import DynamicDML
✗ from econml.dml import DynamicDML
As of v0.14.0, DynamicDML was moved to the `econml.panel` subpackage.

This quickstart demonstrates how to use `CausalForestDML` to estimate Conditional Average Treatment Effects (CATEs) using synthetic data. It involves defining confounders (W), features for heterogeneity (X), treatment (T), and outcome (Y), then fitting the model and predicting CATEs for new feature values. `RandomForestRegressor` and `RandomForestClassifier` are used as base learners for Y and T models respectively.

import numpy as np import pandas as pd from econml.dml import CausalForestDML from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier # Simulate data np.random.seed(42) n_samples = 1000 W = np.random.normal(0, 1, size=(n_samples, 3)) # Confounders X = np.random.normal(0, 1, size=(n_samples, 2)) # Features for heterogeneity T = (W[:, 0] + W[:, 1] + np.random.normal(0, 1, n_samples) > 0).astype(float) # Treatment Y = W[:, 0] + W[:, 2] + T * (X[:, 0] + np.random.normal(0, 0.1, n_samples)) + np.random.normal(0, 1, n_samples) # Outcome # Initialize and fit the CausalForestDML model est = CausalForestDML( model_y=RandomForestRegressor(min_samples_leaf=5, n_estimators=100, random_state=42), model_t=RandomForestClassifier(min_samples_leaf=5, n_estimators=100, random_state=42), cv=5, random_state=42 ) est.fit(Y, T, X=X, W=W) # Estimate CATE for new data (or original X) X_test = np.array([[0.5, 0.5], [-0.5, -0.5]]) cate_estimates = est.effect(X_test) print(f"CATE estimates for X_test: {cate_estimates}") # Expected output: CATE estimates for X_test: [0.67204641 0.44976767]
Debug
Known issues
breakingThe `DynamicDML` estimator was moved from `econml.dml` to `econml.panel`. Direct imports from the old path will raise an `ImportError`.
fix
Update import statements from `from econml.dml import DynamicDML` to `from econml.panel import DynamicDML`.
affects: >=0.14.0
breakingThe default `alpha` value for confidence intervals in methods like `effect_interval` changed from `None` (user-defined or estimator-specific) to `0.05` (representing 95% confidence).
fix
Explicitly set the `alpha` parameter in `effect_interval` or similar methods if you rely on a specific alpha value or wish to restore prior behavior.
affects: >=0.12.0
gotchaEconML v0.16.0 requires `shap` versions `>=0.40.0` and `<0.44.0`. Using `shap` version 0.44.0 or higher will lead to installation conflicts or runtime errors when calling `shap_values`.
fix
Ensure your installed `shap` version is within the compatible range. Downgrade `shap` to `<0.44.0` if you encounter issues (`pip install 'shap<0.44.0'`).
affects: 0.16.0
gotchaThe `deepiv` module, containing the `DeepIV` estimator, requires `tensorflow` and `keras` to be installed separately. These libraries can have strict Python and other dependency version requirements that may cause conflicts.
fix
Install `econml` with the `[deepiv]` extra (`pip install econml[deepiv]`) to ensure the correct `tensorflow`/`keras` versions are pulled, or manually manage these dependencies carefully to avoid conflicts with other parts of your environment.
affects: All versions
gotchaDistributed training features (e.g., for scaling `OrthoLearner`s) rely on the `ray` library, which is an optional dependency and not installed by default.
fix
Install `econml` with the `[ray]` extra (`pip install econml[ray]`) to enable distributed training capabilities.
affects: >=0.15.0
Upgrade
Version history
0.17.0latest on PyPI · released Jul 31, 2026
Audit
Dependencies
numpyrequiredCore numerical operations
scipyrequiredCore numerical operations
pandasrequiredData manipulation
scikit-learnrequiredMachine learning models and utilities
lightgbmrequiredGradient boosting models
shaprequiredFeature importance (SHAP values)
dowhyoptionalCausal inference pipeline integration
tensorflowoptionalRequired for DeepIV estimator
kerasoptionalRequired for DeepIV estimator
rayoptionalRequired for distributed training/scaling
Agent activity
48 hits · last 30 days
node
46
OpenAI (training)
1
Resources