Skip to main content

DeconDTN-Toolkit

License: MIT PyPI - Python Version PyPI - Version

DeconDTN Toolkit is a PyTorch suite containing benchmark datasets and algorithms for confounding effects in text classification.

[Docs] [Dataset Access]

Features

If a dataset is drawn from two different sources, one may be enriched for the outcome of interest (i.e. $P(Y \mid \text{source1}) \neq P(Y \mid \text{source2})$ ). In this situation a model may learn to recognize the data source, and make predictions in accordance with their class distribution, rather than on the basis of relevant features. This scenario, which we refer to as provenance shift, was the primary motivating use case for the development of the DeconDTN toolkit, though the same evaluation framework and methods of mitigation can apply to other confounding variables also.

  • An evaluation framework for assessment of robustness to confounding shifts in which the proportion of positive examples changes with a confounding variable.
  • A range of algorithms with the potential to mitigate for confounding shift
  • A range of benchmark datasets to evaluate performance.

Available Algorithms

The currently available algorithms are:

Send us a PR to add your algorithm! Our implementations use the hyper-parameter grids described here.

Available Datasets

The currently available datasets are:

Installation

Prerequisites

  • Ubuntu 18.04 or higher
  • CUDA 12.1 or higher
  • Python 3.10 or higher
  • pip

Python Package

pip install --index-url https://test.pypi.org/simple/ \
            --extra-index-url https://pypi.org/simple/ \
            decon-dtn-toolkit

From source

# Create virtual environment
uv venv dedtn-env
source dedtn-env/bin/activate  # On Linux/Mac
# dedtn-env\Scripts\activate  # On Windows

# Install the package in editable mode (for development)
uv pip install -e .
Option 2: conda Conda is ideal for managing complex dependencies, especially with CUDA/PyTorch installations. It provides both package and environment management.
# Create environment with Python 3.12
conda create -n dedtn-tool python=3.12
conda activate dedtn-tool

# Install the package in editable mode
pip install -e .
Option 3: venv (Python Built-in) venv is Python's built-in virtual environment tool - lightweight and requires no additional installation. Good for standard Python projects.
# Create virtual environment
python -m venv dedtn-env

# Activate environment
# On Linux/Mac:
source dedtn-env/bin/activate
# On Windows:
# dedtn-env\Scripts\activate

# Install the package
pip install -e .

Verify Installation

After activating your chosen environment, you can verify the installation with:

python -c "import decon_dtn_toolkit; print('DeconDTN-Toolkit installed successfully')"

Quick Start

To train DANN on the Amazon_Reviews dataset

from decon_dtn_toolkit import datasets
from decon_dtn_toolkit.trainer import TrainConfig, Trainer

data_dir = "PATH_TO_Amazon_Reviews_2018"
amazon_reviews = vars(datasets)["Amazon_Reviews_2018"](root=data_dir)
config = TrainConfig(algorithm='DANN')
model = Trainer(dataset=dataset, config=config)
model.train()

Unittest

python -m unittest discover

Acknowledgement

This project is built upon

  • DomainBed - A PyTorch suite containing benchmark datasets and algorithms for domain generalization in computer vision - MIT license
  • WILDS - A benchmark of in-the-wild distribution shifts spanning diverse data modalities and applications - MIT license
  • SubpopBench - A benchmark of subpopulation shift - MIT license

Citation

Below are citations of the DeconDTN line of work.

@inproceedings{ding2024backdoor,
  title={Backdoor adjustment of confounding by provenance for robust text classification of multi-institutional clinical notes},
  author={Ding, Xiruo and Sheng, Zhecheng and Yeti{\c{s}}gen, Meliha and Pakhomov, Serguei and Cohen, Trevor},
  booktitle={AMIA Annual Symposium Proceedings},
  volume={2023},
  pages={923},
  year={2024}
}
@article{ding2025tailoring,
  title={Tailoring task arithmetic to address bias in models trained on multi-institutional datasets},
  author={Ding, Xiruo and Sheng, Zhecheng and Hur, Brian and Tauscher, Justin and Ben-Zeev, Dror and Yeti{\c{s}}gen, Meliha and Pakhomov, Serguei and Cohen, Trevor},
  journal={Journal of Biomedical Informatics},
  pages={104858},
  year={2025},
  publisher={Elsevier}
}
@inproceedings{sheng2025mitigating,
  title={Mitigating confounding in speech-based dementia detection through weight masking},
  author={Sheng, Zhecheng and Ding, Xiruo and Hur, Brian and Li, Changye and Cohen, Trevor and Pakhomov, Serguei VS},
  booktitle={Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  pages={10419--10434},
  year={2025}
}

Key Contributors (listed alphabetically)

Trevor Cohen

Xiruo Ding

Yongsen Tan

Zhecheng Sheng

Metadata

Release files for decon_dtn_toolkit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decon_dtn_toolkit 0.1.1
File Size Uploaded Provenance Actions
decon_dtn_toolkit-0.1.1.tar.gz 133.4 kB Without provenance Details for decon_dtn_toolkit-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for decon_dtn_toolkit 0.1.1
File Interpreter ABI Platform Actions
decon_dtn_toolkit-0.1.1-py3-none-any.whl Python 3 none any Details for decon_dtn_toolkit-0.1.1-py3-none-any.whl

Total release size: 181.3 kB

Release files / decon_dtn_toolkit-0.1.1.tar.gz

Download URL decon_dtn_toolkit-0.1.1.tar.gz
Size 133.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2ded1ad00287738da89964954bdf40c879f185de447528d276e31de77e53db6f
BLAKE2b-256 checksum
How to use checksums
c96fd8a7f5cfe178de9f0ce1689009dcb13945844b2209e9b81328eda60cf22f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / decon_dtn_toolkit-0.1.1-py3-none-any.whl

Download URL decon_dtn_toolkit-0.1.1-py3-none-any.whl
Size 47.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49758c285f12062f5f3140fbd9acbcdac75e895698220436b7b4c22de50ee411
BLAKE2b-256 checksum
How to use checksums
6d33cea92bbdc48afb0928106b78aff6bcc353b0f2039f7d0c72a18f20af2173
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for decon_dtn_toolkit 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page