graphclust.manifold.UMAPEmbedding#

class graphclust.manifold.UMAPEmbedding(n_components=2, *, k=15, min_dist=0.1, spread=1.0, n_epochs=None, learning_rate=1.0, negative_sample_rate=5, init='spectral', random_state=None)[source]#

Bases: _Mapper

Uniform manifold approximation and projection (UMAP; McInnes, Healy and Melville 2018), NumPy implementation.

  1. Fuzzy neighborhood graph. For every sample the distances to its k nearest neighbors are converted to memberships \(w_{ij}=\exp(-(d_{ij}-\rho_i)/\sigma_i)\), with \(\rho_i\) the distance to the nearest neighbor and \(\sigma_i\) chosen so that \(\sum_j w_{ij}=\log_2 k\); the directed graph is symmetrized by the probabilistic t-conorm \(w_{ij}+w_{ji}-w_{ij}w_{ji}\).

  2. Layout. Starting from a spectral embedding of this graph, the map is optimized by stochastic gradient descent on the fuzzy cross-entropy: edges attract their end points with the low-dimensional similarity \((1+a\,d^{2b})^{-1}\) and negative_sample_rate random pairs per edge repel each other. \(a,b\) follow from min_dist and spread.

This implementation updates all edges of an epoch at once (vectorized), which is adequate up to a few ten thousand samples; for large data use the umap-learn package, which implements the same algorithm with approximate nearest neighbors and Numba. The graph is exposed as graph_ for clustering (e.g. with Leiden).