Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Apply EconML for causal inference combining machine learning and econometrics
.claude/skills/brycewang-stanford-econml-causal-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-12 | ✗→✓ | ▲ Improved | 36% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 264% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 37% | 0% |
| case-23 | ✓→✓ | = Same ✓ | 211% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 89% | 0% |
EconML is a Python package developed by Microsoft Research as part of the ALICE (Automated Learning and Intelligence for Causation and Economics) project. It provides a comprehensive suite of methods for estimating heterogeneous treatment effects from observational data, bridging the gap between modern machine learning and classical econometric techniques for causal inference.
Traditional econometric approaches to causal inference often rely on strong parametric assumptions and struggle with high-dimensional data. Pure machine learning methods excel at prediction but do not inherently distinguish correlation from causation. EconML combines the strengths of both paradigms, offering methods that leverage the flexibility of ML for nuisance parameter estimation while maintaining the rigorous causal identification guarantees of econometric theory.
The library implements cutting-edge methods from the academic literature including Double Machine Learning (DML), Causal Forests, Doubly Robust Learners, Orthogonal Random Forests, and Instrumental Variable methods with ML first stages. These tools are essential for researchers across economics, public health, education policy, and any field where understanding causal mechanisms from non-experimental data is critical.
Install EconML via pip:
bashpip install econml
For the full feature set including optional dependencies:
bashpip install econml[all]
EconML builds on top of scikit-learn and integrates with the broader Python data science ecosystem. Core dependencies include numpy, scipy, pandas, scikit-learn, and statsmodels. Optional dependencies for specific estimators include LightGBM and PyTorch.
Verify installation:
pythonimport econml print(econml.__version__) from econml.dml import LinearDML from econml.orf import DMLOrthoForest print("EconML loaded successfully")
Double Machine Learning (DML): The workhorse method for estimating average and heterogeneous treatment effects while controlling for high-dimensional confounders. DML uses cross-fitting and orthogonalization to eliminate regularization bias:
pythonfrom econml.dml import LinearDML, CausalForestDML from sklearn.ensemble import GradientBoostingRegressor # Linear DML for parametric treatment effect estimation est = LinearDML( model_y=GradientBoostingRegressor(), model_t=GradientBoostingRegressor(), cv=5, random_state=42 ) est.fit(Y, T, X=X, W=W) # Get treatment effect estimates with confidence intervals effect = est.effect(X_test) ci = est.effect_interval(X_test, alpha=0.05) print(f"ATE: {est.ate():.4f}") print(f"ATE 95% CI: {est.ate_interval(alpha=0.05)}")
Here Y is the outcome, T is the treatment, X contains effect modifiers (features for heterogeneity), and W contains additional confounders.
Causal Forest DML: Combines DML orthogonalization with Causal Forest estimation for flexible, nonparametric heterogeneous treatment effects:
pythonfrom econml.dml import CausalForestDML cf_est = CausalForestDML( model_y=GradientBoostingRegressor(), model_t=GradientBoostingRegressor(), n_estimators=200, min_samples_leaf=10, cv=5, random_state=42 ) cf_est.fit(Y, T, X=X, W=W) # Heterogeneous treatment effects hte = cf_est.effect(X_test) # Feature importance for treatment effect heterogeneity importances = cf_est.feature_importances_
Doubly Robust Learner: Provides consistent treatment effect estimates when either the outcome model or the propensity score model is correctly specified:
pythonfrom econml.dr import DRLearner from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor dr_est = DRLearner( model_propensity=RandomForestClassifier(), model_regression=RandomForestRegressor(), model_final=RandomForestRegressor(), cv=5 ) dr_est.fit(Y, T, X=X, W=W)
Instrumental Variable Methods: For settings where unobserved confounding is present but valid instruments are available:
pythonfrom econml.iv.dml import DMLIV iv_est = DMLIV( model_y_xw=GradientBoostingRegressor(), model_t_xw=GradientBoostingRegressor(), model_t_xwz=GradientBoostingRegressor(), cv=5 ) iv_est.fit(Y, T, Z=Z, X=X, W=W)
Experiment Analysis: When randomized experiments suffer from non-compliance or attrition, use IV methods in EconML to recover local average treatment effects. The ML-based first stages handle complex relationships between instruments and treatment uptake.
Policy Evaluation: Estimate heterogeneous treatment effects to identify which subpopulations benefit most from an intervention. The CATE (Conditional Average Treatment Effect) estimates can directly inform targeted policy design:
python# Identify subgroups with largest treatment effects import pandas as pd effects_df = pd.DataFrame({ "effect": cf_est.effect(X_test).flatten(), "ci_lower": cf_est.effect_interval(X_test, alpha=0.05)[0].flatten(), "ci_upper": cf_est.effect_interval(X_test, alpha=0.05)[1].flatten() }, index=X_test.index) # Top beneficiaries top_group = effects_df.nlargest(100, "effect")
Sensitivity Analysis: Combine EconML estimates with sensitivity analysis frameworks to assess robustness to potential unobserved confounders. Report how much unmeasured confounding would be required to explain away your findings.
Publication-Ready Results: EconML provides confidence intervals and hypothesis tests based on asymptotic theory, producing results suitable for peer-reviewed publications. Use the summary methods to generate formatted regression-style output.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | pass→pass | 16,390 | 14,723 | -10% | 1 | 1 | 0% | 3,161 | 4,341 | +37% | 0 | 0 | — |
case-23 | pass→pass | 3,315 | 2,007 | -39% | 1 | 1 | 0% | 589 | 1,830 | +211% | 0 | 0 | — |
case-01 | pass→pass | 15,017 | 29,368 | +96% | 1 | 1 | 0% | 2,436 | 4,602 | +89% | 0 | 0 | — |
case-02 | pass→pass | 14,888 | 15,990 | +7% | 1 | 1 | 0% | 2,406 | 4,226 | +76% | 0 | 0 | — |
case-04 | pass→pass | 5,607 | 5,114 | -9% | 1 | 1 | 0% | 1,197 | 2,635 | +120% | 0 | 0 | — |
case-05 | pass→pass | 15,342 | 14,970 | -2% | 1 | 1 | 0% | 3,003 | 4,543 | +51% | 0 | 0 | — |
case-06 | pass→pass | 9,549 | 9,499 | -1% | 1 | 1 | 0% | 1,934 | 3,680 | +90% | 0 | 0 | — |
case-07 | pass→pass | 18,287 | 17,948 | -2% | 1 | 1 | 0% | 3,604 | 4,930 | +37% | 0 | 0 | — |
case-08 | pass→pass | 16,855 | 14,575 | -14% | 1 | 1 | 0% | 2,303 | 4,253 | +85% | 0 | 0 | — |
case-09 | pass→pass | 9,483 | 7,182 | -24% | 1 | 1 | 0% | 1,866 | 3,016 | +62% | 0 | 0 | — |
case-10 | pass→pass | 20,236 | 19,041 | -6% | 1 | 1 | 0% | 3,307 | 4,817 | +46% | 0 | 0 | — |
case-11 | pass→pass | 16,120 | 16,849 | +5% | 1 | 1 | 0% | 2,651 | 4,450 | +68% | 0 | 0 | — |
case-12 | fail→pass | 11,000 | 10,033 | -9% | 1 | 1 | 0% | 2,201 | 2,990 | +36% | 0 | 0 | — |
case-13 | pass→pass | 7,358 | 6,293 | -14% | 1 | 1 | 0% | 1,501 | 2,839 | +89% | 0 | 0 | — |
case-14 | pass→pass | 14,863 | 16,994 | +14% | 1 | 1 | 0% | 2,321 | 4,216 | +82% | 0 | 0 | — |
case-15 | pass→pass | 11,981 | 10,544 | -12% | 1 | 1 | 0% | 1,875 | 3,322 | +77% | 0 | 0 | — |
case-16 | pass→pass | 17,640 | 19,023 | +8% | 1 | 1 | 0% | 2,772 | 4,587 | +65% | 0 | 0 | — |
case-17 | pass→pass | 5,565 | 1,407 | -75% | 1 | 1 | 0% | 932 | 1,754 | +88% | 0 | 0 | — |
case-18 | pass→pass | 17,564 | 20,168 | +15% | 1 | 1 | 0% | 3,013 | 5,004 | +66% | 0 | 0 | — |
case-19 | pass→pass | 4,371 | 2,921 | -33% | 1 | 1 | 0% | 779 | 2,065 | +165% | 0 | 0 | — |
case-20 | pass→pass | 13,925 | 11,815 | -15% | 1 | 1 | 0% | 2,008 | 3,551 | +77% | 0 | 0 | — |
case-21 | pass→pass | 20,925 | 23,881 | +14% | 1 | 1 | 0% | 3,543 | 5,740 | +62% | 0 | 0 | — |
case-22 | fail→pass | 3,109 | 2,218 | -29% | 1 | 1 | 0% | 488 | 1,777 | +264% | 0 | 0 | — |
case-24 | pass→pass | 7,949 | 8,726 | +10% | 1 | 1 | 0% | 1,375 | 2,961 | +115% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +8 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.