Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
EconML is a free, MIT-licensed Python package for estimating how a treatment or intervention changes an outcome, and how that effect differs across units with different observed characteristics (heterogeneous treatment effects). It is maintained under the PyWhy organisation on GitHub, installs with pip install econml, and wraps machine-learning models from scikit-learn inside estimators such as LinearDML and CausalForestDML that return effect estimates with confidence intervals.
What EconML is used for in research
The official documentation says the library is “designed to measure the causal effect of some treatment variable(s) T on an outcome variable Y”, and that it brings several machine-learning techniques for heterogeneous treatment effects together under one Python interface. The target quantity is the conditional average treatment effect (CATE): the average effect of the treatment for units that share a given set of observable characteristics X. A single average effect answers “did the programme work on average?”; a CATE answers “for whom did it work, and by how much?”
The documentation motivates the package with examples from several fields: how a price discount changes demand depending on consumer characteristics, how a drug changes a patient’s clinical response depending on patient characteristics, whether joining a membership programme raises engagement (using an earlier sign-up experiment as an instrument), and how discounts and technical support separately affect revenue. In research terms, it suits questions where the effect is expected to vary and you have data on the variables that drive that variation, whether the data come from a randomised experiment or from observational records where “the treatment was chosen via some unknown policy”.
EconML is an estimation library, not an identification tool. It assumes you have already decided, on subject-matter grounds, which variables you must control for. If you are still working out that causal structure, start with the CASRAI guide to causal analysis and the explainer on confounding variables, and use EconML once the adjustment set is settled.
The four variable roles: Y, T, X and W
Every EconML call is organised around four inputs, and getting them right matters more than the choice of estimator. The double machine learning (DML) page of the documentation defines them as follows.
- Y is the observed outcome.
- T is the treatment or intervention whose effect you want.
- X holds the observable characteristics that drive how the treatment effect varies. The estimator returns the effect as a function of X.
- W holds controls, or confounders, that affect both the treatment and the outcome but are not used to describe effect variation.
The documented DML model is written as Y = θ(X)·T + g(X, W) + ε for the outcome and T = f(X, W) + η for the treatment, where the functions g and f are estimated flexibly by machine learning and are not structurally restricted. Estimation proceeds in stages: predict Y and T from X and W, take the residuals, then regress the outcome residual on the treatment residual (with X-dependent features) to recover θ(X). The documentation notes that cross-fitting is needed for the theoretical guarantees.
The practical consequence is the X versus W decision. A variable in X lets the effect differ across its values; a variable in W is adjusted for but the reported effect does not vary with it. This is the same distinction the CASRAI comparison of effect modification versus confounding draws in epidemiological terms.
How to install or access it
The package is distributed on PyPI as econml and developed at github.com/py-why/EconML. The README gives the installation command:
pip install econml
On the PyPI project page, read on 2026-11-14, the latest release was 0.17.0 (released 2026-07-31), the licence is MIT, and the package requires Python 3.9 or later, with classifiers listed for Python 3.9 through 3.14. The documentation landing page read the same day was labelled version 0.16.0, so a method described in the online docs may differ slightly from the newest release; check econml.__version__ in your own environment when you cite results. If you manage Python environments with Anaconda, the CASRAI guide to installing Anaconda Python covers the environment setup.
Step-by-step: estimate heterogeneous effects with LinearDML
The following steps follow the README example and the DML documentation. Names and call signatures are quoted from those pages.
- Install the package in a clean environment with
pip install econml, as above. - Assemble the four inputs. Y is the outcome column, T the treatment column, X the effect-modifying features and W the confounders. Decide the X versus W split before fitting, using subject-matter knowledge rather than the data.
- Import an estimator and choose nuisance models. The README example uses scikit-learn’s
LassoCVfor both the outcome model and the treatment model:from econml.dml import LinearDML from sklearn.linear_model import LassoCV est = LinearDML(model_y=LassoCV(), model_t=LassoCV()) - Fit. The call order is outcome, treatment, then keyword arguments for the features:
est.fit(Y, T, X=X, W=W)The DML documentation shows the same pattern with lower-case names:
est.fit(y, T, X=X, W=W). - Estimate effects. For new rows of X, the README calls:
est.effect(X_test) est.effect_interval(X_test, alpha=0.05)The DML page also shows
est.const_marginal_effect(X)for the marginal effect of the treatment at each X, andest.effect(X, T0=T0, T1=T1)for the effect of moving from treatment value T0 to T1. - Record the specification. Report the estimator class, the nuisance models, the variables placed in X and in W, and the package version, so the analysis can be reproduced.
Choosing an estimator family
The README groups the estimators by the situation they address, and the data table below lists the classes with the module each is imported from. In brief, the double machine learning family (LinearDML, SparseLinearDML, CausalForestDML, NonParamDML) covers the case where you observe all relevant confounders. The DML documentation lists DML, LinearDML, SparseLinearDML and KernelDML as parametric final stages and NonParamDML and CausalForestDML as fully nonparametric options; the unregularised LinearDML supports confidence intervals through asymptotic normality. Orthogonal random forests, doubly robust learners and meta-learners (XLearner, SLearner, TLearner) are further options listed in the README. When you have a valid instrument, the instrumental-variable classes such as OrthoIV and LinearDRIV apply, and for deciding who should be treated the package offers policy learners (DRPolicyTree, DRPolicyForest) plus interpreters such as SingleTreeCateInterpreter.
The official FAQ gives one piece of selection advice worth repeating: compare estimates across linear and nonlinear models rather than trusting a single specification.
Output and how to read it
effect(X_test) returns a point estimate of the treatment effect for each row of X_test, so the result is a set of unit-level conditional effects rather than one number. effect_interval(X_test, alpha=0.05) returns a lower and an upper bound for each row. Read the two together: a wide interval around a large point estimate is weak evidence of a large effect for that subgroup, and a pattern of intervals that overlap zero across all of X is weak evidence of any effect at all.
Which inference method stands behind the interval depends on the estimator. The official FAQ lists Bootstrap, OLS, Debiased Lasso, Subsampled Honest Forest and OrthoForest Bootstrap of Little Bags as the inference methods in the package, so state which one your estimator used. Two sanity checks follow from the FAQ. First, if an estimate looks implausible, check your code, try several models and consider an unmeasured confounder. Second, models store an out-of-sample fit metric for the final stage, which you can use to compare specifications.
Worked scenario (illustrative composite)
This scenario is an illustrative composite written for this page, not a real study. A research team has a dataset of patients enrolled in a hospital outcomes programme. Y is a recovery score, T is participation (0 or 1), X is age group and baseline severity (the characteristics they expect to modify the effect), and W is referral source and clinic site (variables that influenced both who joined and how they fared). The team fits LinearDML as in step 4, calls effect_interval on a grid of age and severity values, and reports the estimates where the intervals exclude zero as candidate subgroups. They would then repeat the analysis with CausalForestDML and compare, as the FAQ recommends. The key reporting point is that every conclusion remains conditional on the assumption that W contains all relevant confounders.
Troubleshooting
- The estimates look implausible. The official FAQ advises checking the code, trying several models and considering that an unmeasured confounder may be present.
- The linear and nonlinear estimators disagree. The FAQ recommends comparing estimates across linear and nonlinear models; a large disagreement is a reason to report both and examine the standard errors.
- There is no instrument or experiment, and confounders may be unobserved. The FAQ points to DML, OrthoForest and the meta-learners with all observables included, and states that bias remains because “no statistical approach can perfectly isolate the causal effect”.
- You want to test the identification assumptions. The FAQ says these are hard to test and that DoWhy may help; the documentation lists a DoWhy integration (
DoWhyWrapper) and DoWhy refutation tests under Validation. See the CASRAI guide to DoWhy for that workflow. - The goal is prediction. The FAQ states that the library is designed for causal questions, not forecasting.
- Contributing a fix. The FAQ states that contributions need a DCO sign-off (
git commit -s) and that the PyWhy Code of Conduct applies.
Free alternatives
EconML itself is free and open source. Two other open-source Python libraries address related tasks, summarised from each project’s GitHub page.
| Library | What its own page says it is | Licence | Relationship to EconML |
|---|---|---|---|
| DoWhy | A Python library for causal inference that supports explicit modelling and testing of causal assumptions, in four steps: model, identify, estimate, refute | MIT | Can use EconML CATE estimators, for example backdoor.econml.dml.DML |
| CausalML | A Python package offering uplift modelling and causal inference methods built on machine-learning algorithms | Apache 2.0 | Overlapping purpose (heterogeneous effects across users); separate package |
DoWhy is the natural companion rather than a substitute: it covers stating and refuting the causal assumptions, and EconML covers the heterogeneous-effect estimation inside it.
Frequently asked questions
Is EconML free to use?
Yes. The PyPI page read on 2026-11-14 lists the MIT licence, and the package installs with pip install econml.
What Python version does EconML need?
PyPI lists Python 3.9 or later for release 0.17.0, with classifiers for 3.9 through 3.14, as read on 2026-11-14.
Can EconML be used for forecasting?
The official FAQ says the library is designed for causal questions rather than prediction or forecasting.
Does EconML remove confounding bias?
No. The FAQ says that without an instrument, an experiment or full observation of confounders, bias remains and “no statistical approach can perfectly isolate the causal effect”.
How do I get confidence intervals?
Call effect_interval on a fitted estimator, as in the README (est.effect_interval(X_test, alpha=0.05)). The inference method used depends on the estimator class.
Sources
- EconML README, py-why/EconML on GitHub: https://github.com/py-why/EconML (read 2026-11-14)
- econml on PyPI: https://pypi.org/project/econml/ (read 2026-11-14)
- EconML documentation, Overview and Motivation: https://www.pywhy.org/EconML/spec/motivation.html (read 2026-11-14)
- EconML documentation, Double Machine Learning: https://www.pywhy.org/EconML/spec/estimation/dml.html (read 2026-11-14)
- EconML documentation, FAQ: https://www.pywhy.org/EconML/spec/faq.html (read 2026-11-14)
- DoWhy on GitHub: https://github.com/py-why/dowhy (read 2026-11-14)
- CausalML on GitHub: https://github.com/uber/causalml (read 2026-11-14)
Data: EconML estimator classes by method family and import module
Compiled from the EconML README on GitHub: each estimator class named there for double machine learning, orthogonal random forests, instrumental-variable and policy-learning settings, with the method family the README groups it under and the Python module it is imported from.
Period covered: 2026.
| Estimator class | Method family (README grouping) | Import module |
|---|---|---|
| LinearDML | Double machine learning | econml.dml |
| DynamicDML | Double machine learning (panel) | econml.panel.dml |
| DMLOrthoForest | Orthogonal random forest | econml.orf |
| DROrthoForest | Orthogonal random forest | econml.orf |
| OrthoIV | Instrumental variables (DML-based) | econml.iv.dml |
| NonParamDMLIV | Instrumental variables (DML-based) | econml.iv.dml |
| LinearDRIV | Instrumental variables (doubly robust) | econml.iv.dr |
| SparseLinearDRIV | Instrumental variables (doubly robust) | econml.iv.dr |
| ForestDRIV | Instrumental variables (doubly robust) | econml.iv.dr |
| LinearIntentToTreatDRIV | Instrumental variables (intent-to-treat) | econml.iv.dr |
| DRPolicyTree | Policy learning | econml.policy |
| DRPolicyForest | Policy learning | econml.policy |
Sources
- EconML README, py-why/EconML (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







