Skip to main content

Combines logistic regression for estimating density ratios with RU regression to mitigate conditional and covariate shift

Project description

LogReg DRE (Logistic Regression for Density Ratio Estimation)

LogReg DRE is a Python package for implementing regression models with a focus on handling covariate shift via density ratio estimation using logistic regression. This approach is particularly useful in scenarios where the training and test data distributions differ significantly.

Features

  • Data Generation: Customizable data generation for simulating training and testing datasets with different distributions.
  • Density Ratio Estimation: Utilizes logistic regression to estimate density ratios between training and test datasets, which are then used as weights in the loss function to mitigate covariate shift.
  • Regression Models: Includes implementation of standard regression models and RU regression models that leverage estimated density ratios.
  • Visualization: Functionality to visualize training loss and model predictions to evaluate performance and the impact of covariate shift correction.

Installation

https://github.com/szhang120/log-reg-DRE.git cd log_reg_dre pip install .

Usage

The main components of LogReg DRE are contained within the package directory, which includes modules for data generation, model definition, density ratio estimation, and training routines.

Data Generation

from package.data import generate_x_vals x_train = generate_x_vals(P_TRAIN, NUM_PTS) x_test = generate_x_vals(P_TEST, NUM_PTS)

Density Ratio Estimation

from package.density_ratio_estimation import train_logistic_regression, estimate_density_ratio classifier = train_logistic_regression(x_train, x_test) density_ratios = estimate_density_ratio(x_train, classifier)

Model Training

from package.training import train_standard_model, train_RU_model std_model, std_loss = train_standard_model(X_train, Y_train, classifier) ru_models, ru_loss = train_RU_model(X_train, Y_train, gamma_values, classifier)

Visualization

Refer to the visualization section in main.py for examples on how to plot training losses and model predictions.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

log-reg-dre-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

log_reg_dre-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file log-reg-dre-0.1.0.tar.gz.

File metadata

  • Download URL: log-reg-dre-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for log-reg-dre-0.1.0.tar.gz
Algorithm Hash digest
SHA256 91de951850891a08c5734962a82f34569180e4a1dc0b21fc4b9c4f527314a4f6
MD5 e003c168023f70bdfa049bc07e2d3417
BLAKE2b-256 3145cc265c886838334c5093af8c03e41d92c2e85e09c4c3defda906c896fa15

See more details on using hashes here.

File details

Details for the file log_reg_dre-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: log_reg_dre-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for log_reg_dre-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e9562c3bcf9c8100e8f34b72cd58b6c7d5f49d9f9615818ce3c358eb8e80dc1
MD5 135bad48f4870dbb1a502d5c4836b46b
BLAKE2b-256 b9d727b6b7a1f158344a00f9d0e9b1ff9816f7dfc26ca875cb350d8183b1864f

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