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.6.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.6.0
File Size Uploaded
condo-0.6.0.tar.gz 26.6 kB Details

Built distribution (wheel)

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

Total release size: 53.9 kB

Release files / condo-0.6.0.tar.gz

Download URL condo-0.6.0.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
487b9fbb5b210c59d2d22fb5b0ce378edea5d81a3c6b0a04a01f8900af2ba059
BLAKE2b-256 checksum
How to use checksums
c5b6f1d2f6ac74bd8598b54b5c351fe0a68feda577ebf76bbd87a8f338e4031b
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.6.0-py3-none-any.whl

Download URL condo-0.6.0-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50edb30f2b98cf55b50c3e286e5ea0ef9a6bcb07da4b7a1fce9d18f42bd90844
BLAKE2b-256 checksum
How to use checksums
d3ccc3c7120f6386dd207db160faeab24a4a37f3ac4b0f385435d8693afc8083
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

This release

0.6.0 This release

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