py-why / py-why/EconML

Extracting Fitted Honest Forest from CausalForest or DROrthoForest?

Open
#366 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.8k
Forks
827
PR merge metrics
No merged PRs in 30d

Description

Thanks so much for this package! It is great to have all these methods together in a comprehensive library.

I am working on a project and want to calculate a covariate balance test using the honest forest, similar to Figure 2 in this paper (https://arxiv.org/abs/1909.09138). I have also included a screenshot of Figure 2 at the bottom, where the blue dots are the raw differences between treatment and control, the green dots are the differences using matching, and the pink dots are from causal forest matching. In order to do this, I need to first train the CausalForest or DROrthoForest. Then I replace the outcome with each of the pre-treatment features and calculate the 'treatment effect' on the pre-treatment feature.

Do you know how to extract the trained forest? Specifically, here is simulation code based on the example from the documentation site:

import numpy as np
import sklearn
from econml.ortho_forest import ContinuousTreatmentOrthoForest, DROrthoForest
from econml.causal_forest import CausalForest

np.random.seed(123)

T = np.array([0, 1]*60)
W = np.array([0, 1, 2, 0]*30).reshape(-1, 1)
Y = (.2 * W[:, 0] + np.random.uniform(-2,2, len(T))) * T + .5 + np.random.uniform(-1,1, len(T) )

est = CausalForest(n_trees=5, max_depth=2, subsample_ratio=0.5,
                                   model_T=sklearn.linear_model.LogisticRegression(),
                                   model_Y=sklearn.linear_model.LinearRegression())

### What do I call next to recover the trained causalforest?

Thanks so much!

Screen Shot 2021-01-05 at 2 54 03 PM

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CausalForest, DROrthoForest, and ContinuousTreatmentOrthoForest entry points shown in the issue and review the documentation example around model training. Determine whether the trained forest can be extracted through the existing estimator interface; done should be a documented supported approach or a clearly stated limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, scikit-learn
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.