Skip to main content

PCC - Dimensionality reduction with very high global structure preservation

License: MIT Build Status

PCC

PrePrint: https://arxiv.org/abs/2503.07609 Authors: Jacob Gildenblat, Jens Pahnke

pip install pccdr

from pcc import PCUMAP
pcumap_embedding = PCUMAP(device='cuda').fit_transform(X)

⭐ This is a python package for dimensionality reduction (DR) with high global structure preservation.

⭐ That means that unlike in popular DR methods like UMAP, the distances between transformed points - will actually mean something.

⭐ Use PCUMAP for simply enhancing the widely used UMAP method with global structure preservation.

⭐ Or use it with our own PCC objective that resutls with extremely high global structure preservation, and competitive local structure.

(For spearman correlation support, install torchsort (pip install torchsort))

A few visual examples

Image Description
Fashion MNIST An example on the Fashion-Mnist dataset
MSI An application on Mass Spectometry Imaging
Macosko single cell dataset An application illustarting the global structure preservation on the Macosko single cell dataset compared to UMAP

PCC is built on the idea of sampling reference points, meausring distances of all data points from the reference points, and maximizing the correlations of these distances in the high dimensional data, and the transformed low dimensional data.

Usage examples

See examples/macosko.ipynb for more detailed explanation and usage examples.

There are two modes:

Plugging into UMAP, for getting a meaningful transformation where distances between points mean something

Here we use the excellent recent TorchDR library, and add plug in our objective into UMAP.

from pcc import PCUMAP
pcumap_embedding = PCUMAP(device='cuda', n_components=2).fit_transform(X)

PCC as a standalone DR method with a multi task objective

This optimizes a local structure preservation multi task objective that tries to predict which clusters points belong to, as well as global structure preservation loss that maximizes corerlations between distances of all points to sampled reference points.

First, lets cluster the points with different clustering models:

np.random.seed(0)

clusters = []
n_clusters_list = [4, 8, 16, 32, 64]
for n_clusters in n_clusters_list:
    kmeans = KMeans(n_clusters=n_clusters, random_state=0, n_init="auto")
    cluster_labels = kmeans.fit_predict(X)
    clusters.append(cluster_labels)

Then we can call PCC:

pcc_reducer = PCC(n_components=2, num_epochs=2000, num_points=1000, pearson=True, 
                  spearman=False, beta=5, k_epoch=2)
pcc_embedding = pcc_reducer.fit_transform(X, clusters)

Metadata

Release files for pccdr 1.0.3

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

Source distribution (sdist)

Source distribution for pccdr 1.0.3
File Size Uploaded
pccdr-1.0.3.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pccdr 1.0.3
File Interpreter ABI Platform
pccdr-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / pccdr-1.0.3.tar.gz

Download URL pccdr-1.0.3.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bb30e803359ed4748232f422b875ea24c9947f75efb8b84bc9064feacb773233
BLAKE2b-256 checksum
How to use checksums
b4572d9a0c8f6a19f7f379ce36944a035cdbfcf67c4c3589c2e149cabc3d4f3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / pccdr-1.0.3-py3-none-any.whl

Download URL pccdr-1.0.3-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b228427754edc47385d82ebae24e0c1ab99a2fd95e44959dbe880687ecbf35df
BLAKE2b-256 checksum
How to use checksums
84cbfb894ed508d5945dae610881ca29e2be1f4183391fe45936184fd780e05b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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