Skip to main content

Python Package Index

contrastive_inverse_regression

cir is a python package provided the algorithm for contrastive inverse regression (CIR) for dimension reduction used in a supervised setting to find a low-dimensional representation by solving a nonconvex optimization problem on the Stiefel manifold.

Installation

Make sure you have numpy, pandas, and scipy install beforehand and the version of these packages compatible with cir. The easy way to install is using pip:

pip install contrastive-inverse-regression

Alternatively, you can also install by cloning this repository:

pip install git+https://github.com/myueen/cir.git

Dependencies

  • Python (>= 3.10.9)
  • numpy (>= 1.24.3)
  • pandas (>= 2.1.4)
  • scipy (>= 1.9.3)

To run exmaple, matplotlib (>= 3.8.2) is required

Example

The dataset for the following example is included in the example/dataset folder.

import contrastive_inverse_regression
from contrastive_inverse_regression import CIR
import pandas as pd

d = 2
alpha = 0.0001

# download the dataset and set it to the absolute path in your computer 
fg = pd.read_csv('../foregroundX.csv')
bg = pd.read_csv('../backgroundX.csv')
Y = pd.read_csv('../foregroundY.csv')
Yt = pd.read_csv('../backgroundY.csv')

fg = fg.iloc[0:, 1:]
bg = bg.iloc[0:, 1:]
Y = Y.iloc[0:, 1:]
Yt = Yt.iloc[0:, 1:]

V = CIR(fg, Y, bg, Yt, alpha, d)

Other detailed examples for employing cir are provided.

For the case of discrete foreground Y values, the mouse protein dataset Data_Cortex_Nuclear.csv is used and the corresponding visualization in mp_regression.py and regression testing in mp_regression.py.

For the case of continuous foreground Y values, cir is applied on the retinol dataset Retinol.txt and the corresponding regression is in plasma_regression.py. Continuous values are not usually for classification, hence visualization is not provided.

Citing contrastive-inverse-regression

If you find this algorithm helpful in your research, please add the following bibtex citation in references.

@phdthesis{hawke2023contrastive,
  title={Contrastive inverse regression for dimension reduction},
  author={Hawke, Sam and Luo, Hengrui and Li, Didong},
  journal={arXiv preprint arXiv:2305.12287},
  year={2023}
}

References

.. [1] : Hawke, S., Luo, H., & Li, D. (2023) "Contrastive Inverse Regression for Dimension Reduction", Retrieved from https://arxiv.org/abs/2305.12287

.. [2] Harry Oviedo (2024). SGPM for minimization over the Stiefel Manifold (https://www.mathworks.com/matlabcentral/fileexchange/73505-sgpm-for-minimization-over-the-stiefel-manifold), MATLAB Central File Exchange. Retrieved January 12, 2024.

Metadata

Release files for contrastive-inverse-regression 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contrastive-inverse-regression 1.0.13
File Size Uploaded
contrastive_inverse_regression-1.0.13.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contrastive-inverse-regression 1.0.13
File Interpreter ABI Platform
contrastive_inverse_regression-1.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / contrastive_inverse_regression-1.0.13.tar.gz

Download URL contrastive_inverse_regression-1.0.13.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eb0693f9f68f4f9704d8a0d7e71b0c1143c8ff51752465e0e6d345a953feff4f
BLAKE2b-256 checksum
How to use checksums
0ebe7b73c0242fe922c58bbc3a9c3aa94fe7fd8bea7e68a823e6ad661422db4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.7

Release files / contrastive_inverse_regression-1.0.13-py3-none-any.whl

Download URL contrastive_inverse_regression-1.0.13-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79d39518725391bf0f87e998608f309c4b27dfe7299e576bc7d326e59d851c59
BLAKE2b-256 checksum
How to use checksums
8dc78b8bbf3fa9729549477ce9c009d554c7a8431847acc87ba74ea32981d62d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.0.13 This release

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page