Skip to content

Causal trees option to return counterfactual outcomes#623

Merged
jeongyoonlee merged 12 commits into
uber:masterfrom
alexander-pv:feature/outcomes
Jul 8, 2023
Merged

Causal trees option to return counterfactual outcomes#623
jeongyoonlee merged 12 commits into
uber:masterfrom
alexander-pv:feature/outcomes

Conversation

@alexander-pv
Copy link
Copy Markdown
Collaborator

@alexander-pv alexander-pv commented Jun 11, 2023

Proposed changes

Hi,

This feature adds an option for causal trees to return counterfactual outcomes $\hat{Y}(X|T=0)$, $\hat{Y}(X|T=1)$ along with estimated individual treatment effects.

Details:

  • predict() method in CausalTreeRegressor and CausalRandomForestRegressor got flag with_outcomes that enables to return nx3 array of outcomes and treatment effects.
  • Usage example was added to causal_trees_with_synthetic_data.ipynb notebook.
  • New test for causal trees covers columns check in predict() output

Related issues: #590

Update:

  • Dependencies fix: limit numpy version
  • Requirements migration to pyproject.toml.

Types of changes

What types of changes does your code introduce to CausalML?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc. This PR template is adopted from appium.

@alexander-pv alexander-pv changed the title Causal trees option to return outcomes Causal trees option to return counterfactual outcomes Jun 11, 2023
@alexander-pv
Copy link
Copy Markdown
Collaborator Author

alexander-pv commented Jun 27, 2023

I updated package dependencies to make tests pass as expected and suggest moving requirements and metadata from setup.py to pyproject.toml as stated in pep-631 and pep-621

As a bonus, now you don't need to execute python setup.py build_ext --inplace to build cython modules before installing the package! Everything will be installed via pip install . However, it is still a requirement for pytest because test modules still import local causalml directory as a package.

Copy link
Copy Markdown
Collaborator

@jeongyoonlee jeongyoonlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! This will make installation and package management much easier. Really appreciate your contribution - as always!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants