Skip to content
SpecializedSource checked

t-SNE

Embeds high-dimensional points into two or three dimensions while preserving local neighborhoods.

Quick Facts

Compact metadata for implementation and discovery.

Category
Machine Learning
Difficulty
Advanced
Family
Manifold Learning
Tier
Specialized
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
3
Code example
Ready
Visualization
Ready

Overview

t-SNE builds neighbor probabilities in high-dimensional space and optimizes a low-dimensional layout with similar local probabilities.

Core Concepts

neighbor probabilitylow-dimensional embeddingKL divergencelocal structure

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n^2)

Average

O(i n^2)

Worst

O(i n^2)

Space

O(n^2)

When to Use

  • Use when local neighborhood visualization is more important than preserving global distances.
  • Use when visualizing embeddings is a central requirement.

When Not to Use

  • Avoid when the embedding needs stable metric distances or exact cluster sizes.
  • Avoid when the data size, labels, or feature assumptions do not match the model.

What It Does

  • Converts distances into neighbor probabilities
  • Optimizes a low-dimensional embedding
  • Emphasizes local structure

Use Cases

  • Visualizing embeddings
  • Exploring clusters
  • Inspecting high-dimensional datasets

Inputs

  • High-dimensional points
  • Perplexity
  • Output dimension

Outputs

  • 2D or 3D point positions

Key Formulas (1)

Embedding objective

cost = KL(Phigh || Qlow)
cost = KL(P_high || Q_low)

Minimizes mismatch between high-dimensional and low-dimensional neighbor probabilities.

Pseudocode

  1. 1.Compute pairwise similarities in high-dimensional space
  2. 2.Initialize low-dimensional positions
  3. 3.Compute low-dimensional similarities
  4. 4.Move points to reduce probability mismatch
  5. 5.Return the final embedding

Canonical Example

Input
input = 1000 image embeddings
Output
output = 2D scatter plot
Explanation
Similar images tend to land near each other in the plot.

Implementation Notes

  • Run multiple seeds and compare whether local neighborhoods remain stable.
  • Split data for validation and keep preprocessing identical between training and inference.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Changing perplexity or random seed can change the visual story.
  • Evaluating only on training data can hide overfitting and poor generalization.
  • Not defining boundary, empty, or degenerate inputs before implementation.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show high-dimensional neighborhoods pulling nearby 2D points together while others repel.

t-SNE mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: Compute pairwise similarities in high-dimensional space
model-training

Notes

Distances between far-apart clusters in a t-SNE plot are often not meaningful.

Sources (1)

What each reference supports for this entry.

Visualizing Data using t-SNE

Paper

Original t-SNE reference for neighborhood probability matching and low-dimensional embedding optimization.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Conceptual neighborPrincipal Component Analysis

Both reduce dimensionality, but t-SNE preserves local neighborhoods nonlinearly.

Alternative toUMAP

Both are nonlinear dimensionality-reduction methods used for visualization.

Tags

Machine LearningDimensionality ReductionManifold LearningVisualization