Skip to main content

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:
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.

Files for crosstrainer, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size crosstrainer-0.1.5-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page