# t-SNE and UMAP for Visualization

> Nonlinear embeddings that reveal clusters and manifolds in 2D, and how to avoid over-reading their pictures. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/tsne-umap
Last updated: 2026-11-28

Nonlinear embeddings that reveal clusters and manifolds in 2D, and how to avoid over-reading their pictures.

Intermediate · about 3 hours · difficulty 3/5

Learn first: [Principal Component Analysis](https://www.internhack.in/roadmaps/tracks/machine-learning/pca)

t-SNE and UMAP map high-dimensional points (embeddings, images, gene expression) into 2D while trying to keep neighbours close. They produce striking plots that often reveal structure PCA misses.

### Differences

- **t-SNE** focuses on local neighbourhoods; `perplexity` roughly sets neighbourhood size. Slow on large data and has no simple transform for new points.
- **UMAP** is faster, tends to preserve more global structure and can transform new data. `n_neighbors` and `min_dist` are the main knobs.

### Reading the plots honestly

- **Cluster sizes and distances between clusters are not meaningful** in t-SNE plots.
- Different random seeds and hyperparameters give different pictures; try several.
- Apparent clusters can appear in pure noise with poor settings.
- Common practice: PCA to around 50 dimensions first, then t-SNE or UMAP.

### Uses

Inspecting learned embeddings, spotting mislabelled examples, and exploring data before clustering. Use them as exploration tools, not as features for final models without careful validation.

**Good enough to move on** when you can produce t-SNE and UMAP plots of the same data, vary their hyperparameters and explain what conclusions are and are not justified.

## Key concepts

- **t-SNE and perplexity**
- **UMAP parameters**
- **Interpretation caveats**
- **PCA preprocessing**

## Mini project

Embed Fashion-MNIST with PCA, t-SNE and UMAP, color by label, and write three observations plus one conclusion you deliberately refuse to draw.

## Check yourself

In a t-SNE plot, one cluster is twice as large and far from the others. What can you actually conclude?

## Free resources

- [How to Use t-SNE Effectively](https://distill.pub/2016/misread-tsne/) (Distill)
- [UMAP documentation](https://umap-learn.readthedocs.io/en/latest/) (umap-learn)
- [scikit-learn: Manifold learning](https://scikit-learn.org/stable/modules/manifold.html) (scikit-learn)

Previous: [Principal Component Analysis](https://www.internhack.in/roadmaps/tracks/machine-learning/pca) · Next: [Anomaly and Outlier Detection](https://www.internhack.in/roadmaps/tracks/machine-learning/anomaly-detection)

## More in Finding Structure Without Labels

- [k-Means Clustering](https://www.internhack.in/roadmaps/tracks/machine-learning/k-means)
- [Hierarchical and Density-Based Clustering](https://www.internhack.in/roadmaps/tracks/machine-learning/hierarchical-and-density-clustering)
- [Principal Component Analysis](https://www.internhack.in/roadmaps/tracks/machine-learning/pca)
- [t-SNE and UMAP for Visualization](https://www.internhack.in/roadmaps/tracks/machine-learning/tsne-umap)
- [Anomaly and Outlier Detection](https://www.internhack.in/roadmaps/tracks/machine-learning/anomaly-detection)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
