Lensed UMAP
Lensed UMAP provides three methods that apply lens-functions to a UMAP model. Lens functions can be used to untangle embeddings along a particular dimension. This dimension may be part of the data, or come from another information source. Using lens functions, analysts can update their UMAP models to the questions they are investigating, effectively viewing their data from different perspectives.
How to use Lensed UMAP
The lensed UMAP package provides functions that operate on (fitted) UMAP objects.
import numpy as np
import pandas as pd
from umap import UMAP
import lensed_umap as lu
import matplotlib.pyplot as plt
# Load data and extract lens
df = pd.read_csv("./data/five_circles.csv", header=0)
lens = np.log(df.hue)
# Compute initial UMAP model
projector = UMAP(
repulsion_strength=0.1, # To avoid tears in projection that
negative_sample_rate=2, # are not in the modelled graph!
).fit(df[["x", "y"]])
# Draw intial model
x, y = lu.extract_embedding(projector)
plt.scatter(x, y, 2, lens, cmap="viridis")
plt.axis("off")
plt.show()
# Apply a global lens
lensed = lu.apply_lens(projector, lens, resolution=6)
x, y = lu.extract_embedding(lensed)
plt.scatter(x, y, 2, lens, cmap="viridis")
plt.axis("off")
plt.show()
Example Notebooks
A notebook demonstrating how the package works is available at How lensed UMAP Works. The other notebooks demonstrate lenses on several data sets and contain the analyses presented in our paper. The datasets we used as input and the data generated by our notebooks are stored using git lfs, which turns the files in this repository into versioned links to the actual data files. Their documentation explains how to retrieve the actual data files.
Installing
lensed_umap is available on PyPI:
pip install lensed_umap
Citing
A scientific paper describing our work is available on Arxiv:
@misc{bot2024lens,
title={Lens functions for exploring UMAP Projections with Domain Knowledge},
author={Daniel M. Bot and Jan Aerts},
year={2024},
eprint={2405.09204},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
Licensing
The lensed UMAP package has a 3-Clause BSD license.
Metadata
Release files for lensed-umap 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lensed_umap-0.1.3.tar.gz | 15.6 kB | With provenance | Details for lensed_umap-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lensed_umap-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for lensed_umap-0.1.3-py3-none-any.whl |
Total release size: 30.0 kB
Release files / lensed_umap-0.1.3.tar.gz
| Download URL | lensed_umap-0.1.3.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30225c271b1fc8341b499f7fdc9d6e526e7638bbc85ab074a9fe9f01ea67d2ad
|
|
BLAKE2b-256 checksum How to use checksums |
ca5d38dfdd60e37f0656b7efdc9e7adc8b10fca4252bb44eb66e46570574dff9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.
Transparency logRelease files / lensed_umap-0.1.3-py3-none-any.whl
| Download URL | lensed_umap-0.1.3-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea87b19c359bc0b786627e94fe2c8fc13a528852112960d9f5e6d4050012c79b
|
|
BLAKE2b-256 checksum How to use checksums |
abf62fa493cf05e0ecad981e50bb0812b7926420b226506e48e1e0cd68f080e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.
Transparency logSecurity for lensed-umap 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lensed_umap-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 25, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.