Skip to content

Commit 7ccbaf7

Browse files
authored
Merge pull request #739 from erikcs/maq-optional
Remove maq git+pip dependency
2 parents 57332cb + 892bcba commit 7ccbaf7

4 files changed

Lines changed: 20 additions & 21 deletions

File tree

causalml/metrics/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@
3232
SensitivitySubsetData,
3333
SensitivitySelectionBias,
3434
) # noqa
35-
from maq import MAQ, get_ipw_scores # noqa

docs/examples/qini_curves_for_costly_treatment_arms.ipynb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@
77
"source": [
88
"# Qini curves with multiple costly treatment arms\n",
99
"\n",
10-
"This notebook gives a brief overview of Qini curves for multi-armed treatment rules and a simple simulated example."
10+
"This notebook shows approaches to evaluating multi-armed CATE estimators from `causalML` with the Multi-Armed Qini metric available in the `maq` package (available at https://github.com/grf-labs/maq).\n",
11+
"\n",
12+
"\n",
13+
"This metric is a generalization of the familiar *Qini curve* to settings where we have multiple treatment arms available, and the cost of assigning treatment can vary by both unit and treatment arm according to some known cost structure. At a high level, this metric essentially allows you to quantify the value of targeting with more treatment arms by undertaking a cost-benefit exercise that uses your CATE estimates to assign the arm to the unit that is most cost-beneficial at various budget constraints.\n",
14+
"\n",
15+
"This notebook gives a brief overview of the statistical setup and a walkthrough with a simple simulated example. \n",
16+
"\n",
17+
"\n",
18+
"To use this functionality, you first have to install the `maq` Python package from GitHub. The latest source release can be installed with:"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"id": "0a633fa7",
24+
"metadata": {},
25+
"source": [
26+
"```\n",
27+
"pip install \"git+https://github.com/grf-labs/maq.git#egg=maq&subdirectory=python-package\"\n",
28+
"```"
1129
]
1230
},
1331
{
@@ -22,7 +40,7 @@
2240
"from xgboost import XGBRFRegressor\n",
2341
"\n",
2442
"# Generalized Qini curves\n",
25-
"from causalml.metrics import MAQ, get_ipw_scores\n",
43+
"from maq import MAQ, get_ipw_scores\n",
2644
"\n",
2745
"import numpy as np\n",
2846
"np.random.seed(42)"

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ dependencies = [
4545
"torch",
4646
"pyro-ppl",
4747
"graphviz",
48-
"maq@git+https://github.com/grf-labs/[email protected]#egg=maq&subdirectory=python-package",
4948
]
5049

5150
[project.optional-dependencies]

tests/test_metrics.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import pandas as pd
2-
import numpy as np
32
from numpy import isclose
43
from causalml.metrics.visualize import qini_score
5-
from causalml.metrics import MAQ, get_ipw_scores
64

75

86
def test_qini_score():
@@ -28,18 +26,3 @@ def test_qini_score():
2826
# for each learner, its qini score should stay same no matter calling with another model or calling separately
2927
assert isclose(full_result["learner_1"], learner_1_result["learner_1"])
3028
assert isclose(full_result["learner_2"], learner_2_result["learner_2"])
31-
32-
33-
def test_MAQ():
34-
np.random.seed(42)
35-
n = 1000
36-
K = 5
37-
tau_hat = np.random.randn(n, K)
38-
cost = np.random.rand(n, K)
39-
DR_scores = np.random.randn(n, K)
40-
41-
mq = MAQ(n_bootstrap=200)
42-
mq.fit(tau_hat, cost, DR_scores)
43-
44-
# (0.005729002695991717, 0.019814651108894354)
45-
assert isclose(mq.average_gain(spend=0.1)[0], 0.005729)

0 commit comments

Comments
 (0)