Skip to main content

Untangle UMAP with lenses.

Project description

PyPI version Tests

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()

Initial UMAP model

# 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()

Lensed model

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.

Installing

`lensed_umap`` is available on PyPI:

pip install lensed_umap

Citing

A scientific publication of this algorithm and codebase is in progress. Please refer back to this section to see how you can cite this work in the future.

Licensing

The lensed UMAP package has a 3-Clause BSD license.

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

lensed_umap-0.1.0.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

lensed_umap-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file lensed_umap-0.1.0.tar.gz.

File metadata

  • Download URL: lensed_umap-0.1.0.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.9

File hashes

Hashes for lensed_umap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea71796871eb620200026bdf357df4254f1bba6343131e9872a615941ab34a52
MD5 35dcddaee3e08631c0c0e07ba84fee03
BLAKE2b-256 837c1ff8b038716bb5f25f23f445deb2713e6cf9c9de4b41d7fa9939356eb8db

See more details on using hashes here.

File details

Details for the file lensed_umap-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lensed_umap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.9

File hashes

Hashes for lensed_umap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e84a535268eb3cb373364a64f80c31338cd4134771f18e6deb12d81d722e0e90
MD5 d377b2ca84e7a421ced8e754efd0e7d5
BLAKE2b-256 d4f7bd32b9e3c4963c682a60558903a2d8c85e13d85a06cd748a4244572d8f98

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page