Skip to content

Commit 3f3dcbc

Browse files
authored
Merge pull request #11 from CyberAgentAILab/feat/get-started-doc
Update get-started guide
2 parents c820ee4 + f16e23c commit 3f3dcbc

File tree

15 files changed

+284
-253
lines changed

15 files changed

+284
-253
lines changed

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
# Contribution
3+
Thank you for considering contributing to this project! Here are some guidelines to help you get started.
4+
5+
## How can I contribute to this project?
6+
### Reporting Bugs
7+
If you find a bug, please report it by opening an issue in the issue tracker. Provide as much detail as possible to help us understand and reproduce the issue:
8+
- A clear and descriptive title.
9+
- A detailed description of the problem.
10+
- Steps to reproduce the issue.
11+
- Any error messages or screenshots.
12+
13+
### Suggesting Enhancements
14+
We welcome suggestions for improvements! To suggest an enhancement:
15+
- Check the issue tracker to see if someone else has already suggested it.
16+
- If not, open a new issue and describe your idea clearly.
17+
- Explain why you believe the enhancement would be beneficial.
18+
19+
### Pull Requests
20+
Pull requests are welcome! If you plan to make significant changes, please open an issue first to discuss your idea. This helps us ensure that your contribution fits with the project's direction. Follow these steps for a smooth pull request process:
21+
22+
- Fork the repository.
23+
- Clone your fork to your local machine.
24+
- Create a new branch: `git checkout -b my-feature-branch`.
25+
- Make your changes.
26+
- Commit your changes: `git commit -m 'Add some feature'.
27+
- Push to the branch: `git push origin my-feature-branch`.
28+
- Open a pull request in the original repository.
29+
30+
## Development
31+
Here are the basic commands you can use to develop this package.
32+
33+
### Install Pipenv
34+
If you don't have `pipenv` installed, you can install it using `pip`:
35+
36+
```sh
37+
pip install pipenv
38+
```
39+
40+
### Linting
41+
We use `ruff` for linting the code. To run the linter, use the following command:
42+
```sh
43+
pipenv run lint
44+
```
45+
46+
### Auto format
47+
We use `ruff` for formatting the code. To run the formatter, use the following command:
48+
```sh
49+
pipenv run format
50+
```
51+
52+
### Unit test
53+
We use `unittest` for testing the code. To run the unit tests, use the following command:
54+
```sh
55+
pipenv run unittest
56+
```

README.md

Lines changed: 11 additions & 25 deletions
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

@@ -17,29 +17,15 @@ This an a Python package for building the regression adjusted distribution funct
1717
pip install -e .
1818
```
1919

20+
## Basic Usage
21+
Examples of how to use this package are available in [this Get-started Guide](https://cyberagentailab.github.io/python-dte-adjustment/get_started.html).
22+
2023
## Development
24+
We welcome contributions to the project! Please review our [Contribution Guide](CONTRIBUTING.md) for details on how to get started.
25+
26+
## License
27+
28+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
2129

22-
### Install Pipenv
23-
If you don't have `pipenv` installed, you can install it using `pip`:
24-
25-
```sh
26-
pip install pipenv
27-
```
28-
29-
### Linting
30-
We use `ruff` for linting the code. To run the linter, use the following command:
31-
```sh
32-
pipenv run lint
33-
```
34-
35-
### Auto format
36-
We use `ruff` for formatting the code. To run the formatter, use the following command:
37-
```sh
38-
pipenv run format
39-
```
40-
41-
### Unit test
42-
We use `unittest` for testing the code. To run the unit tests, use the following command:
43-
```sh
44-
pipenv run unittest
45-
```
30+
## Maintainers
31+
- [Tomu Hirata](https://github.com/TomeHirata)
-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/contributing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Contribution Guide
2+
==================
3+
4+
Regarding how to contribute to this package, please refer to https://github.com/CyberAgentAILab/python-dte-adjustment/CONTRIBUTING.md for more details.

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

0 commit comments

Comments
 (0)