CrossTrainer: Practical Domain Adaptation with Loss Reweighting
Project description
# CrossTrainer: Practical Domain Adaptation with Loss Reweighting
This is an implementation of the method described in "CrossTrainer: Practical Domain Adaptation with Loss Reweighting" by Justin Chen, Edward Gan, Kexin Rong, Sahaana Suri, and Peter Bailis.
### Install
The crosstrainer package can be installed using pip.
```
pip install crosstrainer
```
### Usage
CrossTrainer utilizes loss reweighting to train machine learning models using data from a target task with supplementary source data.
##### Inputs:
Base model, target data, source data.
##### Outputs:
Trained model with optimized weighting parameter alpha.
##### Example:
```python
import crosstrainer
from sklearn import linear_model
lr = linear_model.LogisticRegression()
ct = CrossTrainer(lr, k=5, delta=0.01)
lr, alpha = ct.fit(X_target, y_target, X_source, y_source)
y_pred = lr.predict(X_test)
```
More examples can be found in the tests file: ```crosstrainer/tests/test_crosstrainer.py```.
This is an implementation of the method described in "CrossTrainer: Practical Domain Adaptation with Loss Reweighting" by Justin Chen, Edward Gan, Kexin Rong, Sahaana Suri, and Peter Bailis.
### Install
The crosstrainer package can be installed using pip.
```
pip install crosstrainer
```
### Usage
CrossTrainer utilizes loss reweighting to train machine learning models using data from a target task with supplementary source data.
##### Inputs:
Base model, target data, source data.
##### Outputs:
Trained model with optimized weighting parameter alpha.
##### Example:
```python
import crosstrainer
from sklearn import linear_model
lr = linear_model.LogisticRegression()
ct = CrossTrainer(lr, k=5, delta=0.01)
lr, alpha = ct.fit(X_target, y_target, X_source, y_source)
y_pred = lr.predict(X_test)
```
More examples can be found in the tests file: ```crosstrainer/tests/test_crosstrainer.py```.
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
crosstrainer-0.1.3.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for crosstrainer-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6076acd25e858579475869d8a7bd5ce75ad0975ce2297ea41c21c8a917aeafa2 |
|
MD5 | 53a23f409548940c6e71e466e7807615 |
|
BLAKE2b-256 | 060c43c6216f6e05f0f3f80511c46e86356d17b51a1acfd537ab418b9422079a |