Confounded domain adaptation
Project description
condo-adapter
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:
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.
Development
Testing
In this directory run
pytest
License Information
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
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
Built Distribution
File details
Details for the file condo-1.0.0.tar.gz
.
File metadata
- Download URL: condo-1.0.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 675f637b96e1640a9ef0e1c224f7c605bf5b18dff9048723122a07796b981031 |
|
MD5 | f14b6e3e9600bfd80b30eadc195a009e |
|
BLAKE2b-256 | 7ceb5dafd3a3b7935c12b54e0e942275670003b631e945b913834957095220fa |
File details
Details for the file condo-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: condo-1.0.0-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f7e1916cddd5d7cab4cb09efe5aedada2935459efc7ef109d538af6f34de0d |
|
MD5 | 14f8654932415e64decab86d54c86a18 |
|
BLAKE2b-256 | 9bcc056e86578e0b1f10ff4c6f7e7863004278d92cb8429b4b8a2ff0dea32bad |