Skip to content

Commit 5f5ee05

Browse files
committed
feat: update sample data
1 parent 67c9b86 commit 5f5ee05

14 files changed

Lines changed: 243 additions & 226 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Overview
22

3-
This an a Python package for building the regression adjusted distribution function estimator proposed in "Estimating Distributional Treatment Effects in Randomized Experiments: Machine Learning for Variance Reduction".
3+
This a Python package for building the regression adjusted distribution function estimator proposed in "Estimating Distributional Treatment Effects in Randomized Experiments: Machine Learning for Variance Reduction". For the details of this package, see [the documentation](https://cyberagentailab.github.io/python-dte-adjustment/).
44

55
## Installation
66

-32.9 KB
Loading

docs/source/_static/dte_moment.png

-40.5 KB
Loading

docs/source/_static/dte_simple.png

-31 KB
Loading
-5.51 KB
Loading

docs/source/_static/pte_simple.png

4.78 KB
Loading

docs/source/_static/qte.png

-20.4 KB
Loading

docs/source/development.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Development Guide
2+
==================
3+
4+
This is a guide to develop this package.
5+
6+
Install Pipenv
7+
~~~~~~~~~~~~~~
8+
If you don't have `pipenv` installed, you can install it using `pip`.
9+
10+
.. code-block:: bash
11+
12+
pip install pipenv
13+
14+
15+
Linting
16+
~~~~~~~
17+
We use `ruff` for linting the code. To run the linter, use the following command.
18+
19+
.. code-block:: bash
20+
21+
pipenv run lint
22+
23+
24+
Auto format
25+
~~~~~~~~~~~
26+
27+
We use `ruff` for formatting the code. To run the formatter, use the following command.
28+
29+
.. code-block:: bash
30+
31+
pipenv run format
32+
33+
34+
Unit test
35+
~~~~~~~~~
36+
37+
We use `unittest` for testing the code. To run the unit tests, use the following command:
38+
39+
.. code-block:: bash
40+
41+
pipenv run unittest
42+
43+
Contribution
44+
~~~~~~~~~~~~
45+
46+
Once you complete your changes, please create a PR to the main branch of https://github.com/CyberAgentAILab/python-dte-adjustment.

docs/source/get_started.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ Generate data for training cumulative distribution function:
4343
quadratic_term = np.dot(X**2, gamma)
4444
4545
# Outcome equation
46-
Y = D + linear_term + quadratic_term + U
46+
Y = 5 * D + linear_term + quadratic_term + U
4747
4848
return X, D, Y
4949
50-
n = 100 # Sample size
50+
n = 1000 # Sample size
5151
X, D, Y = generate_data(n)
5252
5353
Then, let's build an empirical cumulative distribution function (CDF).
@@ -63,13 +63,14 @@ Distributional treatment effect (DTE) can be computed easily in the following co
6363

6464
.. code-block:: python
6565
66-
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=np.sort(Y), variance_type="simple")
66+
locations = np.linspace(Y.min(), Y.max(), 20)
67+
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=locations, variance_type="simple")
6768
6869
A convenience function is available to visualize distribution effects. This method can be used for other distribution parameters including Probability Treatment Effect (PTE) and Quantile Treatment Effect (QTE).
6970

7071
.. code-block:: python
7172
72-
plot(np.sort(Y), dte, lower_bound, upper_bound, title="DTE of simple estimator")
73+
plot(locations, dte, lower_bound, upper_bound, title="DTE of simple estimator")
7374
7475
.. image:: _static/dte_empirical.png
7576
:alt: DTE of empirical estimator
@@ -92,8 +93,8 @@ DTE can be computed and visualized in the following code.
9293

9394
.. code-block:: python
9495
95-
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=np.sort(Y), variance_type="simple")
96-
plot(np.sort(Y), dte, lower_bound, upper_bound, title="DTE of adjusted estimator with simple confidence band")
96+
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=locations, variance_type="simple")
97+
plot(locations, dte, lower_bound, upper_bound, title="DTE of adjusted estimator with simple confidence band")
9798
9899
.. image:: _static/dte_simple.png
99100
:alt: DTE of adjusted estimator with simple confidence band
@@ -105,8 +106,8 @@ Confidence bands can be computed in different ways. In the following code, we us
105106

106107
.. code-block:: python
107108
108-
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=np.sort(Y), variance_type="moment")
109-
plot(np.sort(Y), dte, lower_bound, upper_bound, title="DTE of adjusted estimator with moment confidence band")
109+
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=locations, variance_type="moment")
110+
plot(locations, dte, lower_bound, upper_bound, title="DTE of adjusted estimator with moment confidence band")
110111
111112
.. image:: _static/dte_moment.png
112113
:alt: DTE of adjusted estimator with moment confidence band
@@ -118,8 +119,8 @@ Also, an uniform confidence band is used when "uniform" is specified for the "va
118119

119120
.. code-block:: python
120121
121-
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=np.sort(Y), variance_type="uniform")
122-
plot(np.sort(Y), dte, lower_bound, upper_bound, title="DTE of adjusted estimator with uniform confidence band")
122+
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, locations=locations, variance_type="uniform")
123+
plot(locations, dte, lower_bound, upper_bound, title="DTE of adjusted estimator with uniform confidence band")
123124
124125
.. image:: _static/dte_uniform.png
125126
:alt: DTE of adjusted estimator with uniform confidence band
@@ -131,7 +132,6 @@ To compute PTE, we can use "predict_pte" method.
131132

132133
.. code-block:: python
133134
134-
locations = np.linspace(Y.min(), Y.max(), 20)
135135
pte, lower_bound, upper_bound = estimator.predict_pte(target_treatment_arm=1, control_treatment_arm=0, width=1, locations=locations, variance_type="simple")
136136
plot(locations, pte, lower_bound, upper_bound, chart_type="bar", title="PTE of adjusted estimator with simple confidence band")
137137

docs/source/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
dte_adj Documentation
6+
dte_adj
77
===================================
88

9+
This a Python package for building the regression adjusted distribution function estimator proposed in "Estimating Distributional Treatment Effects in Randomized Experiments: Machine Learning for Variance Reduction".
10+
911
.. toctree::
1012
:maxdepth: 2
1113
:caption: Contents:
1214

1315
installation
1416
get_started
17+
development
1518
modules
1619

1720
Indices and tables

0 commit comments

Comments
 (0)