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!

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:

from condo import ConDoAdapterKLD
condoer = ConDoAdapterKLD()

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, and all code for experiments are in the papers directory.

Development

Testing

In this directory run

pytest

Citing this toolbox

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

In Bibtex format:

@article{
mccarter2024towards,
title={Towards Backwards-Compatible Data with Confounded Domain Adaptation},
author={Calvin McCarter},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2024},
url={https://openreview.net/forum?id=GSp2WC7q0r},
note={}
}

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 1.1.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 1.1.0
File Size Uploaded
condo-1.1.0.tar.gz 30.5 kB Details

Built distribution (wheel)

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

Total release size: 65.2 kB

Release files / condo-1.1.0.tar.gz

Download URL condo-1.1.0.tar.gz
Size 30.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4124bbe99864abd7c90b3949dcc28e5deec62a92914bcfcb23e22e6185cf8277
BLAKE2b-256 checksum
How to use checksums
38c99221642787a30bf86c3e28f335774f08a5a87788a50ac78f3551f2105aea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

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

Download URL condo-1.1.0-py3-none-any.whl
Size 34.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97929c53bfcb5e5d293ffd9f196310ba71b78f45cc9ec8b2e3768a5ff281ef81
BLAKE2b-256 checksum
How to use checksums
47bf85f78f0c081e0483b2eeae3921a3f74fed284898072522e118c90e4ac804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.18

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.8.0

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