Skip to main content

Combines logistic regression for estimating density ratios with RU regression to mitigate distributional shift

Project description

log_reg_dre Package

The log_reg_dre package is a Python library designed to facilitate the training and evaluation of logistic regression models, particularly in scenarios involving distributional shifts such as covariate shift and conditional shift. It includes functionality for density ratio estimation (DRE), enabling robust model training and evaluation under distributional changes. This package is ideal for researchers and practitioners working on machine learning problems where the training and test data distributions may differ.

Features

  • Data Generation: Functions to simulate synthetic datasets that mimic real-world scenarios with distributional shifts.
  • Density Ratio Estimation: Tools to estimate the density ratio between two distributions, aiding in addressing covariate shifts.
  • Estimators: Sklearn-compatible estimator classes for easy integration with existing machine learning pipelines.

Installation

You can install the log_reg_dre package directly from the source using the following command:

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

Usage

Below is a quick start example on how to use the log_reg_dre package to train a logistic regression model with density ratio estimation:

from log_reg_dre.package.data_generation import generate_x_vals
from log_reg_dre.package.density_ratio_estimation import train_logistic_ratio_classifier
from log_reg_dre.package.estimators import StandardEstimator

# Generate synthetic training and test data
x_train, y_train = generate_x_vals(p_val=0.5, num_samples=100)
x_test, y_test = generate_x_vals(p_val=0.5, num_samples=40)

# Train the logistic ratio classifier
classifier = train_logistic_ratio_classifier(x_train, x_test)

# Initialize and train the StandardEstimator
estimator = StandardEstimator(classifier=classifier)
estimator.fit(x_train, y_train)

# Evaluate the model
predictions = estimator.predict(x_test)
print("Model predictions:", predictions)

License

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

Support

For questions and support, please open an issue in the GitHub repository.

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.8.tar.gz (5.1 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.8-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: log-reg-dre-0.1.8.tar.gz
  • Upload date:
  • Size: 5.1 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.8.tar.gz
Algorithm Hash digest
SHA256 f3c9fa40251acf360e02f0cd43011a3347a066e4cfe9f5c30da2a53659bf30e3
MD5 f2c001b38dc06855d438d9d4c57a4616
BLAKE2b-256 f41f6222b7be2efb7c52e0bea21a19358432a08a284c4c106bf1c581f4e238cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: log_reg_dre-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 96f59856dbafde8daddc79e387de0081fa79930e1c582e68495e13346646a8ee
MD5 967752f8fe81b5f40499afd81240e221
BLAKE2b-256 3199deb1a49598f975ccbdc0f3b0d71fab13c9a9166992e2ec013865398889e8

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