policytree

policytree: Policy learning via doubly robust empirical welfare maximization over trees - Published in JOSS (2020)

https://github.com/grf-labs/policytree

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: arxiv.org, wiley.com, joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

causal-inference policy-learning
Last synced: 6 months ago · JSON representation

Repository

Policy learning via doubly robust empirical welfare maximization over trees

Basic Info
Statistics
  • Stars: 83
  • Watchers: 9
  • Forks: 15
  • Open Issues: 14
  • Releases: 0
Topics
causal-inference policy-learning
Created about 6 years ago · Last pushed 7 months ago
Metadata Files
Readme License

README.md

policytree

CRANstatus Build Status

A package for learning simple rule-based policies, where the rule takes the form of a shallow decision tree. Applications include settings which require interpretable predictions, such as for example a medical treatment prescription. This package uses doubly robust reward estimates from grf to find a shallow, but globally optimal decision tree.

Some helpful links for getting started:

Installation

The latest release of the package can be installed through CRAN:

R install.packages("policytree")

To install the latest development version from source:

R devtools::install_github("grf-labs/policytree", subdir = "r-package/policytree")

Installing from source requires a C++ 11 compiler (on Windows Rtools is required as well) together with the R packages Rcpp and BH.

Multi-action policy learning example

```r library(policytree) n <- 250 p <- 10 X <- matrix(rnorm(n * p), n, p) W <- as.factor(sample(c("A", "B", "C"), n, replace = TRUE)) Y <- X[, 1] + X[, 2] * (W == "B") + X[, 3] * (W == "C") + runif(n) multi.forest <- grf::multiarmcausal_forest(X, Y, W)

Compute doubly robust reward estimates.

Gamma.matrix <- doublerobustscores(multi.forest) head(Gamma.matrix)

A B C

1 -0.002612209 -0.1438422 -0.04243015

2 0.417066177 0.4212708 1.04000173

3 2.020414370 0.3963890 1.33038496

4 1.193587749 1.7862142 -0.05668051

5 0.808323778 0.5017521 1.52094053

6 -0.045844471 -0.1460745 -1.56055025

Fit a depth 2 tree on a random training subset.

train <- sample(1:n, 200) opt.tree <- policy_tree(X[train, ], Gamma.matrix[train, ], depth = 2) opt.tree

policy_tree object

Tree depth: 2

Actions: 1: A 2: B 3: C

Variable splits:

(1) splitvariable: X3 splitvalue: 0.368037

(2) splitvariable: X2 splitvalue: -0.098143

(4) * action: 1

(5) * action: 2

(3) splitvariable: X2 splitvalue: 1.25697

(6) * action: 3

(7) * action: 2

Predict treatment on held out data

head(predict(opt.tree, X[-train, ]))

> [1] 2 3 1 2 3 3

```

Details

policy_tree(): fits a depth k tree by exhaustive search (Nxp features on Nxd actions). The optimal tree maximizes the sum of rewards: let $\Gammai \in \mathbb R^d$ be a vector of unit-specific rewards for each action 1 to $d$ and $\pi(Xi) \in \{1, ..., d\}$ a mapping from covariates $Xi$ to action. `policytree` solves the following:

$$ \pi^* = argmax{\pi \in \Pi} \left[\frac{1}{n} \sum{i=1}^{n} \Gammai(\pi(Xi)) \right], $$

where $\Pi$ is the class of depth-k decision trees. (hybrid_policy_tree() employs a mix between a optimal/greedy approach and can be used to fit deeper trees).

double_robust_scores(): computes doubly robust reward estimates for a subset of grf forest types.

Contributing

Contributions are welcome, please consult the development guide for details.

Funding

Development of policytree is supported by the National Science Foundation, the Sloan Foundation, the Office of Naval Research (Grant N00014-17-1-2131) and Schmidt Futures.

References

Susan Athey and Stefan Wager. Policy Learning With Observational Data. Econometrica 89.1 (2021): 133-161. [paper, arxiv]

Toru Kitagawa and Aleksey Tetenov. Who Should be Treated? Empirical Welfare Maximization Methods for Treatment Choice. Econometrica 86.2 (2018): 591-616. [paper]

Erik Sverdrup, Ayush Kanodia, Zhengyuan Zhou, Susan Athey, and Stefan Wager. policytree: Policy learning via doubly robust empirical welfare maximization over trees. Journal of Open Source Software, 5(50), 2020. [paper]

Zhengyuan Zhou, Susan Athey, and Stefan Wager. Offline Multi-Action Policy Learning: Generalization and Optimization. Operations Research 71.1 (2023). [paper, arxiv]

Owner

  • Name: GRF Labs
  • Login: grf-labs
  • Kind: organization
  • Location: Stanford University

JOSS Publication

policytree: Policy learning via doubly robust empirical welfare maximization over trees
Published
June 22, 2020
Volume 5, Issue 50, Page 2232
Authors
Erik Sverdrup ORCID
Stanford Graduate School of Business
Ayush Kanodia
Stanford Graduate School of Business
Zhengyuan Zhou
NYU Stern
Susan Athey
Stanford Graduate School of Business
Stefan Wager
Stanford Graduate School of Business
Editor
Arfon Smith ORCID
Tags
causal inference econometrics

GitHub Events

Total
  • Issues event: 4
  • Watch event: 7
  • Delete event: 1
  • Issue comment event: 4
  • Push event: 1
Last Year
  • Issues event: 4
  • Watch event: 7
  • Delete event: 1
  • Issue comment event: 4
  • Push event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 169
  • Total Committers: 3
  • Avg Commits per committer: 56.333
  • Development Distribution Score (DDS): 0.047
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Erik Sverdrup e****p@g****m 161
Stefan Wager s****r 4
Ayush Kanodia k****h@g****m 4

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 25
  • Total pull requests: 86
  • Average time to close issues: 4 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 13
  • Total pull request authors: 2
  • Average comments per issue: 4.0
  • Average comments per pull request: 0.1
  • Merged pull requests: 80
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 0
  • Average time to close issues: 6 days
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 0
  • Average comments per issue: 1.67
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • njawadekar (6)
  • erikcs (6)
  • hhsievertsen (3)
  • gabriel-ruiz (1)
  • jkortner (1)
  • aczura2024 (1)
  • shafayetShafee (1)
  • MCKnaus (1)
  • beniaminogreen (1)
  • jarkki (1)
  • ZhiyLiu (1)
  • kmrnykgbn (1)
  • if-sudo (1)
Pull Request Authors
  • erikcs (87)
  • kanodiaayush (2)
Top Labels
Issue Labels
question (12) enhancement (3) bug (2) breaking (1) documentation (1) code quality (1)
Pull Request Labels
bug (2) documentation (1)

Packages

  • Total packages: 2
  • Total downloads:
    • cran 672 last-month
  • Total docker downloads: 38
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 2
    (may contain duplicates)
  • Total versions: 18
  • Total maintainers: 1
cran.r-project.org: policytree

Policy Learning via Doubly Robust Empirical Welfare Maximization over Trees

  • Versions: 14
  • Dependent Packages: 1
  • Dependent Repositories: 2
  • Downloads: 672 Last month
  • Docker Downloads: 38
Rankings
Forks count: 5.1%
Stargazers count: 5.1%
Average: 13.6%
Dependent packages count: 18.1%
Dependent repos count: 19.3%
Downloads: 20.3%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-policytree
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 34.8%
Average: 40.2%
Forks count: 40.9%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

r-package/policytree/DESCRIPTION cran
  • R >= 3.5.0 depends
  • Rcpp * imports
  • grf >= 2.0.0 imports
  • DiagrammeR * suggests
  • testthat >= 3.0.4 suggests