Skip to main content

Confounded domain adaptation

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

condo-1.1.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

condo-1.1.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file condo-1.1.0.tar.gz.

File metadata

  • Download URL: condo-1.1.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for condo-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4124bbe99864abd7c90b3949dcc28e5deec62a92914bcfcb23e22e6185cf8277
MD5 fa1040489a79c1146e0c691c0d721420
BLAKE2b-256 38c99221642787a30bf86c3e28f335774f08a5a87788a50ac78f3551f2105aea

See more details on using hashes here.

File details

Details for the file condo-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: condo-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for condo-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97929c53bfcb5e5d293ffd9f196310ba71b78f45cc9ec8b2e3768a5ff281ef81
MD5 9da41b802d86aae53a2110a0dbf80b69
BLAKE2b-256 47bf85f78f0c081e0483b2eeae3921a3f74fed284898072522e118c90e4ac804

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page