Dimensionality Reduction (t-SNE, UMAP Overview)
Part of the Data Science Roadmap
In short
PCA draws straight-line shadows. t-SNE and UMAP bend and fold data to show who sits near whom, which is great for spotting clusters in images, text embeddings or genes.
Advanced, non-linear techniques for visualizing high-dimensional data in 2D or 3D — t-SNE and UMAP preserve local structure well, making them popular for exploring clusters visually, though they're not designed for use as model input features.

Think of it like this
The wedding seating plan
Planning seats for 300 wedding guests, you put close friends and relatives at the same table. Tables of related families sit nearby. Nobody cares if the hall's exact distances match real-life closeness. Only 'who sits with whom' matters. That's what t-SNE and UMAP keep.
Watch it happen
t-SNE vs UMAP
t-SNE
- Keeps close neighbours together
- Slower on very large data
- Key knob: perplexity
UMAP
- Usually faster on big data
- Can transform new points
- Key knob: n_neighbors
Both are mainly for looking at data. Use UMAP for big datasets or when new points must be mapped, t-SNE for small ones. Never read too much into gaps between clusters.
The big ideas
What you need to know
Built for plotting
They squeeze many dimensions into 2 or 3 so you can see clusters. They're mostly not used as model features.
Local beats global
Neighbours stay neighbours. But distances between far-apart clusters, and cluster sizes, are not reliable.
Settings change the picture
Perplexity or n_neighbors controls how local the view is. Try a few values before trusting a pattern.
Runs can differ
Results vary with the random seed. Fix random_state so your plots can be reproduced.
See it in code
Walk through the code
1from sklearn.datasets import load_digits2from sklearn.manifold import TSNE3import matplotlib.pyplot as plt4 5X, y = load_digits(return_X_y=True) # 64 pixel features6emb = TSNE(n_components=2, perplexity=30, random_state=0).fit_transform(X)7 8plt.scatter(emb[:, 0], emb[:, 1], c=y, cmap="tab10", s=5)9plt.colorbar()10plt.show()11# UMAP: pip install umap-learn, then umap.UMAP(n_neighbors=15).fit_transform(X)1/3Each 8 by 8 image is 64 numbers.
1,797 handwritten digits with 64 pixels each, squeezed to 2D. Each digit usually forms its own island.
Save yourself the pain
Common mistakes
Oops
Saying 'cluster A is twice as far from B as from C' from a t-SNE plot.
Do this instead
Only trust who is near whom. Global distances and cluster sizes in t-SNE plots are not meaningful.
Oops
Feeding t-SNE output into a model as features for new data.
Do this instead
Use PCA, or UMAP's transform, when new points must be mapped the same way later.
Your mission
PCA vs t-SNE on digits
Quick check
What can you safely read from a t-SNE plot?
Go deeper
- 1Visualize a high-dimensional dataset in 2D using t-SNE or UMAP and compare to PCA.
- 2Learn why t-SNE/UMAP are primarily visualization tools, not general-purpose preprocessing.
- 3Understand these techniques are non-deterministic — rerunning can produce different layouts.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.