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:
_MapperUniform manifold approximation and projection (UMAP; McInnes, Healy and Melville 2018), NumPy implementation.
Fuzzy neighborhood graph. For every sample the distances to its
knearest 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}\).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_raterandom pairs per edge repel each other. \(a,b\) follow frommin_distandspread.
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-learnpackage, which implements the same algorithm with approximate nearest neighbors and Numba. The graph is exposed asgraph_for clustering (e.g. with Leiden).