Metrics to evaluate dimensionality reduction quality.
Project description
ReduMetrics
ReduMetrics is a lightweight library to evaluate the quality of dimensionality reductions, independent of the projection method (PCA, t-SNE, UMAP, …).
It provides five complementary metrics:
| Metric | Meaning | Range |
|---|---|---|
| ULSE | Local neighborhood preservation | [0, 1] |
| RTA | Random triplet accuracy | [0, 1] |
| Spearman | Rank correlation of sampled distances | [−1, 1] |
| k-NCP | k-nearest class preservation | [0, 1] |
| CDC | Centroid distance correlation | [−1, 1] |
Pure functions — NumPy in/out.
Tested with Python 3.9 – 3.12.
Dependencies:
numpy, scipy, scikit-learn
Installation
pip install ReduMetrics
Usage
from ReduMetrics.metrics.ulse import ulse_score
from ReduMetrics.metrics.rta import rta_score
from ReduMetrics.metrics.spearman import spearman_correlation
from ReduMetrics.metrics.k_ncp import kncp_score
from ReduMetrics.metrics.cdc import cdc_score
# X_high: (m, n) high-dim data, X_low: (m, r) embedding, labels: (m,)
rng = np.random.default_rng(42)
m, n, r = 1000, 50, 2
X_high = rng.normal(size=(m, n))
X_low = X_high[:, :r] # toy projection
labels = rng.integers(0, 10, size=m)
# Metrics
ulse = ulse_score(X_high, X_low, k=10) # -> [0, 1]
rta = rta_score (X_high, X_low, T=10000, random_state=0) # -> [0, 1]
rho = spearman_correlation(X_high, X_low, P=20000, random_state=0) # -> [-1, 1]
kncp = kncp_score(X_high, X_low, labels) # -> [0, 1]
cdc = cdc_score (X_high, X_low, labels) # -> [-1, 1]
print(ulse, rta, rho, kncp, cdc)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redumetrics-0.1.0.tar.gz.
File metadata
- Download URL: redumetrics-0.1.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1222874126679d98aea204b6630f8f25a879f3905723282f78baa3aa60c98c11
|
|
| MD5 |
cd8009d81f7e2d5911a9c1858b1837a1
|
|
| BLAKE2b-256 |
14dfcc5cd01f8cf2d7bab63a1ea562ae3c7c2448c3a750c71b3d675a15c0604f
|
File details
Details for the file redumetrics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: redumetrics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3cd639245fde76df88fb68cceb17b7062ee11c88890460fdbc8bdfec527d3a7
|
|
| MD5 |
438320ba80ffaeba42c92214d74618a1
|
|
| BLAKE2b-256 |
3d83b805b68485ce31a5e99fc8d7b08ca6d85820a3e87f950a8c2b78a7149847
|