Diagnostics for dimensionality reduction methods such as t-SNE and UMAP
Project description
dr-diagnostics
dr-diagnostics is a Python package for visual diagnostics of dimensionality
reduction embeddings.
It helps users inspect how well a low-dimensional embedding preserves structure from the original high-dimensional data. The package supports user-provided embeddings, as well as built-in workflows for t-SNE and UMAP.
Installation
Install from PyPI:
pip install dr-diagnostics
Or, for development, from the project root in editable mode:
pip install -e .
Features
- Visualize original data and low-dimensional embeddings, with optional named class legends.
- Compare high-dimensional and low-dimensional Euclidean distances (distance-fit plots).
- Approximate geodesic distances using a k-nearest-neighbour graph and compare them against low-dimensional Euclidean distances.
- Compute rank matrices from pairwise distance matrices and compare high-dimensional ranks with low-dimensional ranks.
- Trustworthiness and continuity curves over a range of neighbourhood sizes.
- Compare t-SNE similarity matrices
PandQ, and UMAP similarity matricesVandW. - Generate a six-panel dashboard combining the diagnostics in one figure.
- Inspect a single selected point and its k-nearest neighbours across all panels, or a specific pair of points (with automatic detection of the most distorted pairs).
- Show the true 3D scatter of the original data when it is three-dimensional (e.g. the Swiss Roll).
Quick start
from sklearn.datasets import load_iris
from dr_diagnostics import run_diagnostics
iris = load_iris()
class_labels = {i: name for i, name in enumerate(iris.target_names)}
fig, results = run_diagnostics(
X_original=iris.data,
method="tsne", # or "umap"
color_values=iris.target,
class_labels=class_labels,
compute_geodesic=True,
)
fig.savefig("iris_diagnostics.png", dpi=300, bbox_inches="tight")
run_diagnostics returns the dashboard figure and a results dictionary
containing the embedding, distance and rank matrices, and similarity matrices.
These can be passed to selected_point_dashboard or selected_pair_dashboard
for local inspection.
License
This project is licensed under the MIT License.
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 dr_diagnostics-0.3.2.tar.gz.
File metadata
- Download URL: dr_diagnostics-0.3.2.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8d5deb1f0004a562a216456acde06035256859fc9793cf556250cdbc47a822d
|
|
| MD5 |
3b9e2f2792048496f5a4a1a85d2e1a4e
|
|
| BLAKE2b-256 |
20bf7aa9c2a2435bdca73c586e4f08c7bc0f8baedff538d3363da5e5edb6b6bf
|
File details
Details for the file dr_diagnostics-0.3.2-py3-none-any.whl.
File metadata
- Download URL: dr_diagnostics-0.3.2-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e277b2578962cd7f6bc7f7443717c69334e985b391527a40c9febdbfde4d2cf1
|
|
| MD5 |
9c1edf2fa9582d607512a0f40843c4f9
|
|
| BLAKE2b-256 |
28348f381f835c3313f1879b760c86590d37150bf346d204316f01af151fb160
|