Skip to content
ML Visualization

PCA vs t-SNE vs UMAP

PCA is a linear projection that preserves global variance, while t-SNE and UMAP are nonlinear neighbor embeddings that preserve local structure. That means PCA keeps large-scale geometry honest, distances and directions retain meaning, but it can miss curved structure, while t-SNE and UMAP reveal clusters vividly but distort distances between them. PCA is also the only one of the three that gives you an explicit, reusable transformation: you get axes you can project new data onto, invert, and interpret through feature loadings.

t-SNE and UMAP solve a similar problem, keep nearby points nearby in 2D, but with different machinery. t-SNE matches neighbor probabilities between the high-dimensional and low-dimensional spaces, and its perplexity knob sets the neighborhood size. UMAP builds a weighted nearest-neighbor graph and optimizes a low-dimensional layout of that graph. In practice UMAP runs faster, scales to larger datasets, preserves somewhat more global arrangement, and unlike classic t-SNE can transform new points after fitting.

The three are complements, not rivals. A standard workflow uses PCA first to denoise and compress, say to 30 or 50 dimensions, then runs t-SNE or UMAP on the reduced data for a 2D picture. Whatever you choose, read neighbor embeddings with care: cluster sizes, inter-cluster distances, and apparent density in a t-SNE or UMAP plot are artifacts of the optimization, not facts about your data.

Side by side

Core idea

Principal Component Analysis

Rotate the data to the orthogonal directions of greatest variance and keep the top few as new axes.

t-SNE

Convert pairwise similarities into neighbor probabilities and find a 2D layout that matches them, keeping close points close.

UMAP

Build a weighted k-nearest-neighbor graph of the data and optimize a low-dimensional layout that preserves that graph's structure.

Linear or nonlinear

Principal Component Analysis

Linear; the embedding is a rotation and projection, so straight-line structure and directions survive.

t-SNE

Nonlinear; it can unfold curved manifolds and separate clusters no linear projection could split.

UMAP

Nonlinear; like t-SNE it captures curved structure, with a graph-based objective instead of probability matching.

What it preserves

Principal Component Analysis

Global variance and relative distances along the retained components; large-scale geometry stays meaningful.

t-SNE

Local neighborhoods; which points are near each other is faithful, while global arrangement is largely arbitrary.

UMAP

Local neighborhoods plus some global arrangement; relative cluster positions tend to be more trustworthy than in t-SNE.

What it distorts

Principal Component Analysis

Nonlinear structure; a curved manifold can collapse onto itself, and small-variance but informative directions get discarded.

t-SNE

Inter-cluster distances and cluster sizes; gaps and blob areas in the plot do not measure real separation or spread.

UMAP

Distances and densities are still distorted, and it can fragment continuous structure into false-looking clusters.

Key hyperparameters

Principal Component Analysis

Number of components, chosen by explained-variance ratio; feature scaling beforehand matters more than any knob.

t-SNE

Perplexity, roughly the effective neighborhood size, typically 5 to 50, plus learning rate and iteration count.

UMAP

n_neighbors trades local versus global emphasis, and min_dist controls how tightly points pack in the layout.

Speed and scalability

Principal Component Analysis

Very fast; essentially an eigendecomposition or truncated SVD, routine on millions of rows.

t-SNE

Slowest of the three; Barnes-Hut and interpolation variants help, but large datasets remain painful.

UMAP

Much faster than t-SNE and comfortable at hundreds of thousands of points.

Transforming new data

Principal Component Analysis

Trivial; PCA is an explicit linear map, so you project new points with a matrix multiply and can invert it.

t-SNE

Not supported in the classic algorithm; you must re-run the embedding, and parametric variants are a separate tool.

UMAP

Supported; a fitted UMAP model can embed new points, though the transform is approximate.

Determinism

Principal Component Analysis

Deterministic up to sign flips of the components; the same data gives the same answer.

t-SNE

Stochastic; different seeds give visibly different layouts, so conclusions should survive multiple runs.

UMAP

Stochastic; more stable than t-SNE run-to-run, but the layout still varies with the seed.

Interpretability of axes

Principal Component Analysis

Components have loadings, so you can read which original features drive each axis.

t-SNE

Axes are meaningless; only neighborhood relationships in the plot carry information.

UMAP

Axes are meaningless here too; read cluster membership and neighbors, never coordinates.

Typical use cases

Principal Component Analysis

Preprocessing and compression before other models, decorrelating features, denoising, and quick first-look plots.

t-SNE

Publication-quality 2D visualizations of clusters in embeddings, single-cell data, and other high-dimensional point clouds.

UMAP

Exploratory visualization at scale, general nonlinear reduction, and pipelines that must embed new data after fitting.

When to use Principal Component Analysis

  • You need dimensionality reduction as input to another model, not just a picture, and want a fast, deterministic, invertible transform.
  • You want to know which original features drive the variation, via component loadings and explained-variance ratios.
  • You must embed new data cheaply in production with a single matrix multiply.
  • You are preprocessing before t-SNE or UMAP to reduce noise and computation, a standard first step.
  • Your data's structure is roughly linear, or you only need to remove correlation rather than uncover manifolds.

When to use t-SNE

  • You want the sharpest possible visual separation of clusters in a 2D figure and the dataset is modest, up to tens of thousands of points.
  • Local neighborhood fidelity matters more than global layout, for example checking whether known classes form coherent groups.
  • You can afford to run it several times at different perplexities to confirm the structure is real.
  • You are producing a one-off exploratory or publication figure rather than a reusable transformation.

When to use UMAP

  • You need t-SNE-style cluster visualization but the dataset is large and t-SNE is too slow.
  • You care about the relative arrangement of clusters, not just their existence, and want more global structure preserved.
  • You need to embed new points after fitting, which classic t-SNE cannot do.
  • You want a nonlinear reduction to more than two dimensions as features for a downstream model, used with appropriate caution.

The bottom line

Use PCA whenever the output feeds another computation: it is fast, deterministic, interpretable, and reversible, and it should almost always run first as a denoising step anyway. For visualization, default to UMAP: it is faster than t-SNE, handles large datasets, keeps more global arrangement, and can embed new points. Reach for t-SNE when you want the most locally faithful picture of a modest dataset and are willing to tune perplexity and rerun with different seeds. And regardless of which embedding you plot, never quote distances, cluster sizes, or densities from a t-SNE or UMAP figure as evidence; verify any structure you see with numbers computed in the original space.

Frequently asked questions

Should I run PCA before t-SNE or UMAP?
Usually yes. Reducing to roughly 30 to 50 principal components first removes noise dimensions, speeds up the neighbor search dramatically, and rarely hurts the result. Most reference implementations either do this by default or recommend it for high-dimensional inputs like images or text embeddings.
Why do my t-SNE clusters move around every time I run it?
t-SNE optimizes a non-convex objective from a random start, so each run finds a different layout. Neighborhoods should be consistent across runs even though positions and orientations change. If a cluster only appears at one seed or one perplexity, treat it as an artifact, not a discovery.
Can I measure distances between clusters in a UMAP plot?
No. UMAP preserves more global arrangement than t-SNE, so relative positions are more suggestive, but the objective only tries to preserve the neighbor graph. Distances between clusters, cluster areas, and apparent densities are not calibrated. Compute real distances in the original or PCA space instead.
What does perplexity actually control in t-SNE?
Perplexity sets the effective number of neighbors each point cares about, typically 5 to 50. Low values emphasize very local structure and can shatter data into many small blobs; high values merge fine structure into broader groups. Sweeping a few values and comparing is the standard sanity check.
Is it valid to cluster on t-SNE or UMAP coordinates?
It is common but risky. Both methods can fabricate visually separate blobs from continuous data and distort densities, so a clustering algorithm applied to the 2D coordinates inherits those artifacts. If you do it, validate the clusters against the original features, or cluster in PCA space instead.