t-SNE and UMAP beside PCA

Layouts that preserve who is near whom, at the cost of making the distance between clusters meaningless.

t-SNE and UMAP beside PCA

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

PCA is a linear projection: it keeps the directions of greatest variance, so global distances survive.
t-SNE and UMAP optimise a layout so that near neighbours stay near. Nothing constrains anything else.
The distance between clusters in a t-SNE plot carries no information. Neither does cluster size.
The layout on this page is a simplified neighbour-preserving optimisation, not t-SNE itself — it shows the behaviour, not the algorithm.

Overview

PCA is a linear projection onto directions with high variance. A two-dimensional PCA plot shows how much of the original variation those two components retain, but it can hide structure in omitted dimensions. PCA does not preserve every pairwise distance when reducing dimensions.

In this guide
  1. Three different projections
  2. Compare the layouts
  3. What the plot can and cannot tell you
  4. Choosing a method
  5. Common mistakes with t-SNE and UMAP beside PCA
  6. Sources and next steps

t-SNE constructs a layout that tries to keep nearby points together. UMAP builds a neighbourhood graph and optimizes a low-dimensional representation of it. Both are nonlinear and can produce useful views of local structure. Neither plot is a faithful map of all high-dimensional distances.

Compare the layouts

The visualization starts from groups with known spacing and compares how each method lays them out. Switch between PCA and the neighbourhood methods, then change the local-neighbourhood setting. The groups may remain visibly separated even as their displayed gaps change. This shows why cluster separation in the picture is useful for exploration but not proof that the groups are globally far apart in the original data.

What the plot can and cannot tell you

  • Nearby points: a t-SNE or UMAP plot is designed to emphasize local neighbourhoods, but validate the neighbourhoods in the original feature space.
  • Gaps between groups: do not interpret these as meaningful global distances; the layout objective may not constrain them.
  • Cluster size and density: plot area can be distorted. It does not directly report the original cluster size or density.
  • Axes: the orientation and absolute coordinates have no direct meaning; rotating or reflecting a layout does not change its interpretation.
  • Stability: results can depend on initialization, random seed, and settings. Compare multiple runs and parameter choices before treating a pattern as robust.

Choosing a method

Use PCA for a fast, interpretable linear baseline and when a fitted transform for new data is useful. Use t-SNE to inspect local neighbourhoods, especially in smaller datasets; adding new points generally requires fitting the embedding again. UMAP can often transform new points after fitting and can scale to larger datasets, but the result still depends on its metric and neighbourhood settings. Neither method should be selected solely because its plot looks more separated.

These are primarily exploratory tools. Before using projected coordinates in a predictive model, validate the full projection-and-model pipeline on held-out data and check whether the representation generalizes to new observations.

Common mistakes with t-SNE and UMAP beside PCA

  • Claiming clusters are proven by the plot: separation may be an artifact of the embedding objective.
  • Reading exact distances or density from t-SNE: those global quantities are not preserved.
  • Showing one run as definitive: repeat with different seeds and reasonable settings.
  • Calling PCA invertible after reducing dimensions: omitted components cannot be recovered exactly.

Sources and next steps

Check yourself

0 of 3

Answer without scrolling back up.

  1. Why can you not read the distance between two clusters in a t-SNE plot?

  2. What can UMAP do that t-SNE cannot?

  3. Why is PCA the safer choice for dimensionality reduction inside a pipeline?

Cheat sheet

t-SNE and UMAP beside PCA

Project high-dimensional data with PCA, t-SNE and UMAP side by side. Learn which visual patterns are real structure and which are artifacts.

MACHINE LEARNING · vizlearn.in/machine_learning/tsne_and_umap.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.