Unsupervised LearningNon-Linear Manifold LearningDimensionality Reduction

t-SNE

Primary task · Dimensionality Reduction

t-SNE is an unsupervised learning method in the non-linear manifold learning family. This page summarizes its mechanism, practical uses, important trade-offs, and a browser-based concept explorer.

← Directory
Visual intuition

From data to learned behaviour

t-SNE converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Infographic
1Data2Initial state3Optimise4Validate5InferenceTraining transforms evidence into a reusable model state
Conceptual simulation

Watch the learning mechanism form

The structure below is synchronized with the same training state used by the prediction simulation.

Mechanism view
Training control centre

Control both simulations together

Reset regenerates the synthetic data and model state. Train animates to completion. Pause freezes the animation. Train Step advances one learning stage.

Step 0 / 12
Model simulation

Inspect the learned prediction / representation

Synthetic data are generated locally in your browser.

Model description

Understand t-SNE after watching it learn

This section connects the animation to the actual statistical or computational idea behind the model.

Deep description

t-SNE t-SNE is an unsupervised learning method in the non-linear manifold learning family. This page summarizes its mechanism, practical uses, important trade-offs, and a browser-based concept explorer.

What is learned. During training, the algorithm builds or adjusts the parameters and internal representation used by t-SNE. The core learning mechanism is: Converts pairwise similarities into probabilities and minimizes the Kullback-Leibler divergence between high- and low-dimensional distributions.

How training becomes inference. Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference. Once training stops, the fitted state is reused on unseen inputs rather than being reconstructed from scratch. The resulting output is: A lower-dimensional embedding or transformed representation designed to preserve selected structure.

Why practitioners use it. Exceptional visualization of tight local neighborhood clusters in 2D or 3D. Typical fits include Visualizing complex high-dimensional feature embeddings, deep learning latent space inspection.

What to verify before trusting it. Slow O(n^2); fails to preserve global distances; cannot project new unseen data points without retraining. The visual simulation is intentionally simplified, so real use should still validate preprocessing, data independence, hyperparameters, uncertainty and task-appropriate metrics.

Internal statethe parameters and internal representation used by t-SNE
Typical outputA lower-dimensional embedding or transformed representation designed to preserve selected structure.
Good fitVisualizing complex high-dimensional feature embeddings, deep learning latent space inspection.
Main cautionSlow O(n^2); fails to preserve global distances; cannot project new unseen data points without retraining.
1Training data→
2Learning objective→
3Internal model state→
4Prediction / representation→
5Evaluation
Intuition

What the model is trying to learn

t-SNE converts patterns in observed data into a reusable prediction or representation rule. The most useful way to understand it is to watch what internal structure changes during training and how that learned structure changes outputs.

Mathematical lens

Core logic

Converts pairwise similarities into probabilities and minimizes the Kullback-Leibler divergence between high- and low-dimensional distributions. The mathematical objective determines which model states are considered better, while regularisation and validation constrain how much complexity should be trusted.

Training sequence

How learning progresses

Prepare data → initialise the model state → evaluate the current objective → update parameters or structure → validate progress → use the final state for inference.

Original mechanism

Taxonomy description

Converts pairwise similarities into probabilities and minimizes the Kullback-Leibler divergence between high- and low-dimensional distributions.

Evaluation guide

How to evaluate this model responsibly

ValidationChoose validation that matches the independence assumptions of the data.
MetricsUse task-specific primary and complementary metrics.
HPOEstablish a baseline first, then search the parameters that materially change capacity.
Post-processingValidate any downstream transformation on held-out data.
Hyperparameters

Key parameters

perplexityTypical: 30

Effective local neighborhood size.

learning_rateTypical: auto

Gradient-descent step scale.

max_iterTypical: 1000

Optimization iterations.

initTypical: pca

Embedding initialization.

Use & trade-offs

Where it fits

Typical applications

Visualizing complex high-dimensional feature embeddings, deep learning latent space inspection.

Strengths

Exceptional visualization of tight local neighborhood clusters in 2D or 3D.

Limitations

Slow O(n^2); fails to preserve global distances; cannot project new unseen data points without retraining.

Code example

Minimal Python implementation

# Purpose: demonstrate t-SNE with a small, inspectable example.
# Follow the comments and printed stages to connect each operation with its result.
# Import the library or helper used in this example.
from sklearn.datasets import load_iris
# Import the library or helper used in this example.
from sklearn.manifold import TSNE

# Print this intermediate result so you can verify the workflow step by step.
print("STEP 1 · Load a 4D dataset")
# Store this intermediate value with a descriptive name for the next step.
X, y = load_iris(return_X_y=True)
# Print this intermediate result so you can verify the workflow step by step.
print("Original shape:", X.shape)
# Print this intermediate result so you can verify the workflow step by step.
print("STEP 2 · Optimise a 2D neighbourhood-preserving embedding")
# Learn the transformation from this data and apply it in one step.
Z = TSNE(n_components=2, perplexity=20, init="pca", learning_rate="auto", random_state=42).fit_transform(X)
# Print this intermediate result so you can verify the workflow step by step.
print("STEP 3 · Inspect the embedding")
# Print this intermediate result so you can verify the workflow step by step.
print("Embedding shape:", Z.shape)
# Print this intermediate result so you can verify the workflow step by step.
print("First point:", Z[0].round(2).tolist())
Expected / representative output
STEP 1 · Load a 4D dataset
Original shape: (150, 4)
STEP 2 · Optimise a 2D neighbourhood-preserving embedding
STEP 3 · Inspect the embedding
Embedding shape: (150, 2)
First point: [-32.290000915527344, -3.549999952316284]