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.8.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.8.0
File Size Uploaded
condo-0.8.0.tar.gz 23.3 kB Details

Built distribution (wheel)

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

Total release size: 52.0 kB

Release files / condo-0.8.0.tar.gz

Download URL condo-0.8.0.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
79e5be350484a1c8e99e8e277284d46c0a020896fe68a7a0528c208d712bf68b
BLAKE2b-256 checksum
How to use checksums
5f472232458e943dcd04eeca1307481aa33ea3892a549f25309698a7b93bb388
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

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

Download URL condo-0.8.0-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4034d24ddeb458aecd1cb0a6e9280ea01b4da433162f841f92c878a7f16cf0ed
BLAKE2b-256 checksum
How to use checksums
66f1cbad3062d54135d39c097fac94c3d38249b71edef44fca634af13e5fd7bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.0

2 release files

This release

0.8.0 This release

2 release files

0.6.0

2 release files

0.5.0

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