Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
with:
python-version: '3.11'

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Install dependencies
run: |
pipenv install --dev --system
uv sync --dev

- name: Build documentation
run: |
cd docs
make html
uv run make html

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install -r requirements-dev.txt
uv sync --dev

- name: Lint with ruff
run: |
ruff check .
uv run ruff check .

- name: Run unit tests
run: |
python -m unittest
uv run python -m unittest
13 changes: 9 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ jobs:
with:
python-version: '3.11'

- name: Install dependencies
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
uv tool install build
uv tool install twine

- name: Build package
run: |
python -m build
uv run python -m build

- name: Publish package to PyPI
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ cython_debug/

# Used for experiments
*.csv
experiments
experiments
37 changes: 23 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,38 @@ Pull requests are welcome! If you plan to make significant changes, please open
- Open a pull request in the original repository.

## Development
Important commands and major dependencies are managed in Pipenv. Here are the basic commands you can use to develop this package.
Important commands and major dependencies are managed with uv. Here are the basic commands you can use to develop this package.

### Install Pipenv
If you don't have `pipenv` installed, you can install it using `pip`:
### Install Dependencies
Install all development dependencies using uv:

```sh
pip install pipenv
uv sync --dev
```

### Linting
We use `ruff` for linting the code. To run the linter, use the following command:
### Pre-commit Hooks
We use pre-commit hooks to automatically format code and check for issues. Install them with:

```sh
uv run pre-commit install
```

### Manual Commands

#### Linting
We use `ruff` for linting the code. To run the linter manually:
```sh
pipenv run lint
uv run ruff check
```

### Auto format
We use `ruff` for formatting the code. To run the formatter, use the following command:
#### Auto format
We use `ruff` for formatting the code. To run the formatter manually:
```sh
pipenv run format
uv run ruff format
```

### Unit test
We use `unittest` for testing the code. To run the unit tests, use the following command:
#### Unit test
We use `unittest` for testing the code. To run the unit tests:
```sh
pipenv run unittest
```
uv run python -m unittest
```
25 changes: 0 additions & 25 deletions Pipfile

This file was deleted.

1,027 changes: 0 additions & 1,027 deletions Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ We welcome contributions to the project! Please review our [Contribution Guide](
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Maintainers
- [Tomu Hirata](https://github.com/TomeHirata)
- [Tomu Hirata](https://github.com/TomeHirata)
2 changes: 1 addition & 1 deletion docs/source/api/local.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ AdjustedLocalDistributionEstimator
:members:
:undoc-members:
:show-inheritance:
:no-index:
:no-index:
2 changes: 1 addition & 1 deletion docs/source/api/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ This page documents plotting utilities for visualizing distribution treatment ef
:members:
:undoc-members:
:show-inheritance:
:no-index:
:no-index:
2 changes: 1 addition & 1 deletion docs/source/api/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ AdjustedDistributionEstimator
:inherited-members:
:undoc-members:
:show-inheritance:
:no-index:
:no-index:
2 changes: 1 addition & 1 deletion docs/source/api/stratified.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ AdjustedStratifiedDistributionEstimator
:inherited-members:
:undoc-members:
:show-inheritance:
:no-index:
:no-index:
4 changes: 2 additions & 2 deletions docs/source/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The dte_adj package provides several types of estimators for computing distribut
* **Simple Randomization Estimators**: For estimating distributional effects in simple randomized experiments where treatment assignment is independent of all covariates
* **Covariate Adaptive Randomization Estimators**: For estimating distributional effects under covariate-adaptive randomization (CAR) designs, including stratified block randomization and other adaptive schemes
* **Local Distribution Estimators**: For estimating local distribution treatment effects weighted by treatment propensity within strata
* **Utility Functions**: Helper functions for confidence intervals and statistical computations
* **Utility Functions**: Helper functions for confidence intervals and statistical computations
* **Plotting Utilities**: Visualization tools for treatment effects and distributions

For theoretical foundations, see Byambadalai et al. (2024) [#simple2024]_ for simple randomization and Byambadalai et al. (2025) [#car2025]_ for covariate-adaptive randomization.
Expand All @@ -33,4 +33,4 @@ Detailed Documentation
api/simple
api/stratified
api/local
api/plot
api/plot
2 changes: 1 addition & 1 deletion docs/source/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contribution Guide
==================

Regarding how to contribute to this package, please refer to https://github.com/CyberAgentAILab/python-dte-adjustment/blob/main/CONTRIBUTING.md for more details.
Regarding how to contribute to this package, please refer to https://github.com/CyberAgentAILab/python-dte-adjustment/blob/main/CONTRIBUTING.md for more details.
18 changes: 9 additions & 9 deletions docs/source/get_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ Generate data for training cumulative distribution function:
"""
# Generate covariates X from a uniform distribution on (0, 1)
X = np.random.uniform(0, 1, (n, d_x))

# Generate treatment variable D from a Bernoulli distribution with success probability rho
D = np.random.binomial(1, rho, n)

# Define beta_j and gamma_j according to the problem statement
beta = np.zeros(d_x)
gamma = np.zeros(d_x)

# Set the first 50 values of beta and gamma to 1
beta[:50] = 1
gamma[:50] = 1

# Compute the outcome Y
U = np.random.normal(0, 1, n) # Error term
linear_term = np.dot(X, beta)
quadratic_term = np.dot(X**2, gamma)

# Outcome equation
Y = 5 * D + linear_term + quadratic_term + U

return X, D, Y

n = 1000 # Sample size
Expand All @@ -56,7 +56,7 @@ Then, let's build an empirical cumulative distribution function (CDF).

import dte_adj
from dte_adj.plot import plot

estimator = dte_adj.SimpleDistributionEstimator()
estimator.fit(X, D, Y)
locations = np.linspace(Y.min(), Y.max(), 20)
Expand Down Expand Up @@ -159,7 +159,7 @@ To compute QTE, you can use ``predict_qte`` method. The confidence band is compu
:width: 450px
:align: center

You can use any model with ``predict_proba`` or ``predict`` method to adjust the distribution function estimation.
You can use any model with ``predict_proba`` or ``predict`` method to adjust the distribution function estimation.
For example, the following code use XGBoost classifier to estimate the conditional distribution.

.. code-block:: python
Expand All @@ -178,4 +178,4 @@ To enable the feature, pass ``is_multi_task=True``.
model = LinearRegression()
estimator = dte_adj.AdjustedDistributionEstimator(model, folds=3)
estimator.fit(X, D, Y)
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, is_multi_task=True, locations=locations, variance_type="moment")
dte, lower_bound, upper_bound = estimator.predict_dte(target_treatment_arm=1, control_treatment_arm=0, is_multi_task=True, locations=locations, variance_type="moment")
6 changes: 3 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dte_adj
A Python Package for Estimating Distribution Treatment Effects
--------------------------------------------------------------

`dte_adj` is a Python package for estimating distribution treatment effects in randomized experiments.
`dte_adj` is a Python package for estimating distribution treatment effects in randomized experiments.
It provides APIs for conducting regression adjustment to estimate precise distribution functions, enabling deeper insights beyond average treatment effects through machine learning-enhanced estimation methods.

.. image:: _static/distributional_effect.png
Expand All @@ -27,7 +27,7 @@ Theoretical Foundations

For theoretical foundations, see:

* **Simple randomization**: Byambadalai et al. (2024) [#simple2024]_
* **Simple randomization**: Byambadalai et al. (2024) [#simple2024]_
* **Covariate-adaptive randomization**: Byambadalai et al. (2025) [#car2025]_
* **Multi-task learning**: Byambadalai et al. (2024) [#multitask2024]_

Expand Down Expand Up @@ -55,4 +55,4 @@ Indices and tables

License
~~~~~~~
MIT License
MIT License
Loading