Skip to main content

Generalizable and Efficient Approximate Spectral Embeddings

Project description

GrEASE

This is the official PyTorch implementation of GrEASE from the paper "Generalizable Spectral Embedding with Applications to UMAP.
One of many applications of ScaSE is UMAP initialization, as shown in the following figure:

Initializing UMAP with ScaSE results in a similar embedding to the one obtained by UMAP itself (initialized with Spectral Embedding), but with a much faster runtime for a large number of samples.

Installation

To install the package, simply use the following command:

pip install grease

Usage

The basic functionality is quite intuitive and easy to use, e.g.,

from grease import GrEASE

grease = GrEASE(n_components=10)  # n_components is the number of dimensions in the low-dimensional representation
grease.fit(X)  # X is the dataset and it should be a torch.Tensor
X_reduced = grease.transfrom(X)  # Get the low-dimensional representation of the dataset
Y_reduced = grease.transform(Y)  # Get the low-dimensional representation of a test dataset

You can read the code docs for more information and functionalities.

Out of many applications, ScaSE can be used for UMAP initialization, Fiedler vector and value approximation, and Diffusion Maps approximation. The following is examples of how to use ScaSE for each of these applications:

UMAP initialization

from scase import ScaSE
from umap import UMAP

scase = ScaSE(n_components=2)
se = scase.fit_transform(X)
umap = UMAP(n_components=2, init=se)
X_reduced = umap.fit_transform(X)

Fiedler vector and value approximation

from scase import ScaSE

scase = ScaSE(n_components=1)
fiedlerVector = scase.fit_transform(X)
fiedlerValue = scase..get_eigenvalues()

Diffusion Maps approximation

from scase import ScaSE

scase = ScaSE(n_components=10)
diffusionMaps = scase.fit_transform(X, t=5)  # t is the diffusion time

Running examples

In order to run the model on the moon dataset, you can either run the file, or using the command-line command:
python -m examples.reduce_moon
This will run the model on the moon dataset and plot the results.

The same can be done for the circles dataset:
python -m examples.reduce_circles

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

grease_embeddings-0.1.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grease_embeddings-0.1.0-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grease_embeddings-0.1.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for grease_embeddings-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b03fc35d932276f92f67c91955f132c1db513af41472ac8cf41f9d1e9c87d2a
MD5 d70bbcc1e89298fb2cbd676c202e5f0a
BLAKE2b-256 6b7bcbf596bd8c0213d63a8e2f865c50b07a64077e33be20875beb35b34d3a4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for grease_embeddings-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7e4aa2775befd7419d61bc99c2c95856d4bf0327d7e338e49c3d86dc32d3362
MD5 a3c41d9c6075aa413022f07ac7aebf89
BLAKE2b-256 67366a10287701a9969c62738cb0b82f619b22fe48788cda1da481939fc56795

See more details on using hashes here.

Supported by

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