Skip to main content

Supervised independent subspace principal component analysis

Project description

Supervised Independent Subspace Principal Component Analysis (sisPCA)

DOI License

Overview

sispca is a Python package designed to learn linear representations capturing variations associated with factors of interest in high-dimensional data. It extends the Principal Component Analysis (PCA) to multiple subspaces and encourage subspace disentanglement by maximizing the Hilbert-Schmidt Independence Criterion (HSIC). The model is implemented in PyTorch and uses the Lightning framework for training. See the documentation for more details.

For more theoretical connections and applications, please refer to our paper Disentangling Interpretable Factors with Supervised Independent Subspace Principal Component Analysis.

What's New

  • v1.1.0 (2025-02-27): Memory-efficient handling of supervision kernel for large datasets.
  • v1.0.0 (2024-10-11): Initial release.

Installation

Via GitHub (latest version):

pip install git+https://github.com/JiayuSuPKU/sispca.git#egg=sispca

Via PyPI (stable version):

pip install sispca

Getting Started

Basic usage:

import numpy as np
import torch
from sispca import Supervision, SISPCADataset, SISPCA

# simulate random inputs
x = torch.randn(100, 20)
y_cont = torch.randn(100, 5) # continuous target
y_group = np.random.choice(['A', 'B', 'C'], 100) # categorical target
L = torch.randn(100, 20)
K_y = L @ L.T # custom kernel, (n_sample, n_sample)
# K_y better be sparse for memory efficiency, i.e. a graph Laplacian kernel

# create a dataset with supervision
sdata = SISPCADataset(
    data = x.float(), # (n_sample, n_feature)
    target_supervision_list = [
        Supervision(target_data=y_cont, target_type='continuous'),
        Supervision(target_data=y_group, target_type='categorical'),
        Supervision(target_data=None, target_type='custom', target_kernel = K_y)
    ]
)

# fit the sisPCA model
sispca = SISPCA(
    sdata,
    n_latent_sub=[3, 3, 3, 3], # the last subspace will be unsupervised
    lambda_contrast=10,
    kernel_subspace='linear',
    solver='eig'
)
sispca.fit(batch_size = -1, max_epochs = 100, early_stopping_patience = 5)

Tutorials:

For additional details, please refer to the documentation.

Citation

If you find sisPCA useful in your research, please consider citing our paper:

  @misc{su2024disentangling,
    title={Disentangling Interpretable Factors with Supervised Independent Subspace Principal Component Analysis},
    author={Jiayu Su and David A. Knowles and Raul Rabadan},
    year={2024},
    eprint={2410.23595},
    archivePrefix={arXiv},
    primaryClass={stat.ML},
    url={https://arxiv.org/abs/2410.23595},
  }

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

sispca-1.1.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

sispca-1.1.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file sispca-1.1.0.tar.gz.

File metadata

  • Download URL: sispca-1.1.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for sispca-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e16b45820d350130490411d9c74938d7874c007ebbbb398691fd794339dd09f6
MD5 5079df372c85a2add728ab98e75681cf
BLAKE2b-256 a197e21bc95eb0e88113ed2328e9e225f918911038ee9241198cb2d0cb8f5269

See more details on using hashes here.

File details

Details for the file sispca-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sispca-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for sispca-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 531ff261b1b0a494bc39bf2269694a664461aed844051cc0332aefa8e04c4f80
MD5 e772fdf0b86cedf1c9768ebcca6ce89b
BLAKE2b-256 fe8940f1d120c4eac45715da13c0d399d36aaea26c9823f1ec95274d06e48e79

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