Skip to main content

condo-adapter

PyPI version Downloads CC BY-NC-SA 4.0

ConDo Adapter performs Confounded Domain Adaptation, which corrects for batch effects while conditioning on confounding variables. We hope it sparks joy as you clean up your data!

Using and citing this toolbox

If you use this toolbox in your research and find it useful, please cite ConDo using the following reference to our arXiv preprint:

In Bibtex format:

@misc{https://doi.org/10.48550/arxiv.2203.12720,
  doi = {10.48550/ARXIV.2203.12720},
  url = {https://arxiv.org/abs/2203.12720},
  author = {McCarter, Calvin},
  title = {Towards Backwards-Compatible Data with Confounded Domain Adaptation},
  publisher = {arXiv},
  year = {2022},
}

Installation

Installation from pip

You can install the toolbox through PyPI with:

pip install condo

Note: If you have issues with importing torchmin, you may need to install from source, as shown below. Or you can try re-installing pytorch-minimize from source.

Installation from source

After cloning this repo, install the dependencies on the command-line via:

pip install -r requirements.txt

In this directory, run

pip install -e .

Usage

Import ConDo and create the adapter:

import condo
condoer = condo.ConDoAdapter()

Try using it:

import numpy as np
X_T = np.sort(np.random.uniform(0, 8, size=(100, 1)))
X_S = np.sort(np.random.uniform(4, 8, size=(100, 1)))
Y_T = np.random.normal(4 * X_T + 1, 1 * X_T + 1)
Y_Strue = np.random.normal(4 * X_S + 1, 1 * X_S + 1)
Y_S = 5 * Y_Strue + 2
condoer.fit(Y_S, Y_T, X_S, X_T)
Y_S2T = condoer.transform(Y_S)
print(f"before ConDo: {np.mean((Y_S - Y_Strue) ** 2):.3f}")
print(f"after ConDo:  {np.mean((Y_S2T - Y_Strue) ** 2):.3f}")

More thorough examples are provided in the examples directory.

Development

Testing

In this directory run

pytest

Code formatting

The Uncompromising Code Formatter: Black
black {source_file_or_directory}

Install it into pre-commit hook to always commit well-formatted code:
pre-commit install

License Information

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

Metadata

Release files for condo 0.5.0

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

Source distribution (sdist)

Source distribution for condo 0.5.0
File Size Uploaded
condo-0.5.0.tar.gz 26.6 kB Details

Built distribution (wheel)

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

Total release size: 53.9 kB

Release files / condo-0.5.0.tar.gz

Download URL condo-0.5.0.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
66f168ceea26065cc67be21213d0161c243ba97a2689b6debd379c3bf2c480ca
BLAKE2b-256 checksum
How to use checksums
4beff577a335cb803ba7fab1e389b4957ca9a153982d7a1b7cac744b1ba45af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release files / condo-0.5.0-py3-none-any.whl

Download URL condo-0.5.0-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
979e2001edc2daaa41bcd56172e93863dfa529f56eda46f98cd807f7cef8d80e
BLAKE2b-256 checksum
How to use checksums
d2a65cc8a2d1c17580d52a0f4d7b2bc1482638ad3e6ee3f2a212e158a0776994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.1.0

2 release files

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