Code for the TMLR paper:
The Shape of Attraction in UMAP: Exploring the Embedding Forces in Dimensionality Reduction
This repository contains code for analyzing attraction and repulsion forces in UMAP and related dimensionality reduction methods. The main idea is to study the scalar “shape” of attractive and repulsive updates, and to use these shapes to explain learning-rate annealing, cluster formation, random-initialization behavior, and the relationship between UMAP, NEG-t-SNE, PaCMAP, and related methods.
UMAP and related neighbor-embedding methods are usually described as algorithms that pull similar points together and push dissimilar points apart. In this work, we make this intuition more explicit by decomposing the update forces into:
- an attraction shape, which controls how positive/neighborhood edges move;
- a repulsion shape, which controls how negative/non-neighbor edges move.
This decomposition reveals that attraction in UMAP is more subtle than simple contraction: depending on the distance and learning rate, attractive updates can either contract or expand the distance between neighboring points. This helps explain why UMAP relies on learning-rate annealing and why random initialization can lead to inconsistent embeddings.
Given two embedding points
and
where
The values of
For UMAP, these shapes are
and
Attraction and repulsion shapes of different algorithms. Left: attraction shapes. Right: repulsion shapes. The condition
The attraction shape directly correlates with the internal chaotic behavior of updates. Shapes that fall below
Exploring the optimization landscape by modifying attraction shapes under random initialization. More blue in the corner indicates more stable optimization outcomes.
Controlling granularity and inter-cluster distance by modifying the shapes. Attraction drives cluster formation, while repulsion controls inter-cluster distance. Modifying them independently can create new clusters or make previously formed clusters more compact.
If you find this paper or codebase useful, please consider citing our paper:
@article{islam2026shape,
title={The Shape of Attraction in UMAP: Exploring the Embedding Forces in Dimensionality Reduction},
author={Islam, Mohammad Tariqul and Fleischer, Jason W},
journal={Transactions on Machine Learning Research},
year={2026}
}



