← Back to the collection
LEARNING / 2026 / INTERACTIVE APPLICATION

Finding order in a cloud of points.

Clustering 3D Lab

Four clustering methods. One spatial laboratory. A way to see not just where an algorithm lands, but why it gets there.

MEDIUM
  • TypeScript
BUILT WITH
  • React
  • Three.js
  • React Three Fiber
  • Vite
ACCESS

Public source

Clustering 3D Lab showing two partitions of a double helix and live diagnostics
EXPLORE THE APPLICATIONLaunch Project
Original application · K-means on a double helix.Open film ↗
01

The premise

An algorithm can converge and still miss the structure in front of it. This lab puts K-means, K-medoids, DBSCAN, and Gaussian mixtures against the same three-dimensional datasets, including deliberately awkward ones: interlocking moons, concentric shells, and a double helix.

02

One operation at a time

Assignment and representative updates are separate states. The interface can pause between them, so the relationship between a changed assignment, a moving centroid, and a lower objective becomes inspectable. Gaussian mixtures expose expectation and maximization; DBSCAN performs a density expansion rather than pretending to share the same steps.

SYSTEM SKETCH / CONCEPTUAL OVERVIEW
INPUT                 MODEL                 VIEW
13 datasets    →    assign / update    →    3D observations
seed + settings     convergence state      hulls + diagnostics
                         ↑                       │
                         └──── step / inspect ───┘
A reading of the architecture, not an application screenshot.
SYSTEM MAP / ALGORITHM STATE FLOW

The model advances; the scene explains each step.

Dataset + initialization → Membership step: centroid / mixture methods. Membership step → Representative step: advanceModel. Representative step → Membership step: not yet converged. Representative step → Movement < 0.001: movement threshold. Dataset + initialization → DBSCAN: density method. Representative step → PointCloud + diagnostics: model. Movement < 0.001 → PointCloud + diagnostics: final model. DBSCAN → PointCloud + diagnostics: labels + noise.1234567801 / READYDataset + initializationmakePoints(seed, dataset)initializeCentroids(strategy)02 / ASSIGNEDMembership stepNearest representativeOr Gaussian expectation03 / UPDATEDRepresentative stepMeans / medoidsOr Gaussian maximization04 / CONVERGEDMovement < 0.001Retain final modelOtherwise assign again05 / DENSITY EXPANSIONDBSCANNeighbour radius + min pointsCluster labels / noise06 / VIEWPointCloud + diagnosticsInstanced meshes + convex hullsInertia / cost / NLL / noise
  1. 01 / ready

    Dataset + initialization

    makePoints(seed, dataset)

    initializeCentroids(strategy)

    • centroid / mixture methods → 2. Membership step
    • density method → 5. DBSCAN
  2. 02 / assigned

    Membership step

    Nearest representative

    Or Gaussian expectation

    • advanceModel → 3. Representative step
  3. 03 / updated

    Representative step

    Means / medoids

    Or Gaussian maximization

    • not yet converged → 2. Membership step
    • movement threshold → 4. Movement < 0.001
    • model → 6. PointCloud + diagnostics
  4. 04 / converged

    Movement < 0.001

    Retain final model

    Otherwise assign again

    • final model → 6. PointCloud + diagnostics
  5. 05 / density expansion

    DBSCAN

    Neighbour radius + min points

    Cluster labels / noise

    • labels + noise → 6. PointCloud + diagnostics
  6. 06 / view

    PointCloud + diagnostics

    Instanced meshes + convex hulls

    Inertia / cost / NLL / noise

    1. 1Dataset + initialization Membership stepcentroid / mixture methods
    2. 2Membership step Representative stepadvanceModel
    3. 3Representative step Membership stepnot yet converged
    4. 4Representative step Movement < 0.001movement threshold
    5. 5Dataset + initialization DBSCANdensity method
    6. 6Representative step PointCloud + diagnosticsmodel
    7. 7Movement < 0.001 PointCloud + diagnosticsfinal model
    8. 8DBSCAN PointCloud + diagnosticslabels + noise
    DBSCAN has its own expansion procedure. It does not use the assignment/update cycle of centroid methods. Gaussian components are spherical.
    Read from the implementation
    • app/KMeansLab.tsx · makePoints
    • initializeCentroids / advanceModel
    • runDbscan / expectationStep
    • PointCloud / ClusterShell
    03

    A visual layer with a job to do

    Instanced meshes render observations. Convex hulls outline the extent of each cluster. Point inspection reveals coordinates and membership, while algorithm-specific diagnostics report inertia, medoid cost, density noise, or negative log-likelihood. The picture and the numbers describe the same model.

    04

    Five years, eight familiar points

    The original 2021 Python project grouped eight 2D observations and printed its iterations. That exact dataset is still an option in this lab. The newer project adds seeded datasets, initialization choices, automatic playback, and an interface for testing the assumptions behind the result.

    05

    The useful limitation

    The Gaussian model uses spherical components, and centroid methods do not preserve curved topology. Those constraints are part of the experiment. A neat-looking partition is an invitation to inspect the model, not proof that it found the right answer.

    CONTINUE EXPLORING

    Word Embeddings →

    Ten thousand words, each with 200 dimensions. A browser-based exploration of relationships, analogies, and the space between meanings.

    2024—2026
    • JavaScript