← AI Terminology
Clustering (K-Means, DBSCAN)
Clustering is an unsupervised learning task that groups data points into clusters based on similarity, without predefined labels.
K-Means and DBSCAN are the two most widely used clustering algorithms, each suited to different data shapes.
K-Means and DBSCAN are the two most widely used clustering algorithms, each suited to different data shapes.
Why It Matters in AI
Clustering is how you find structure in data when you don't know what categories exist in advance — customer segmentation, topic modelling, anomaly detection, and image compression all use clustering. It's often the first step in exploratory data analysis and a core component of unsupervised representation learning pipelines.
Key Points
| Aspect | Description |
|---|---|
| DBSCAN | Density-based: clusters = high-density regions; noise = isolated points — handles arbitrary shapes |
| HDBSCAN | Hierarchical DBSCAN — finds clusters at varying densities; generally preferred over DBSCAN |
| K-Means | Assigns each point to the nearest centroid; iterates until centroids stabilise — fast, spherical clusters |
| Evaluation | Silhouette score, Davies-Bouldin index — no ground truth labels needed for unsupervised metrics |
| K selection | K-Means requires specifying K: Elbow method, Silhouette score, or domain knowledge |
| Hierarchical | Agglomerative clustering builds a dendrogram — choose cut level to get desired cluster count |
Simple Analogy
Sorting a pile of mixed vegetables without labels: you naturally group carrots together, tomatoes together, broccoli together. K-Means does this by repeatedly finding the centre of each group and reassigning members; DBSCAN does it by finding dense neighbourhoods and treating sparse regions as between-group gaps.
Common Usage Examples
KMeans(n_clusters=5).fit(X)— customer segmentation on purchase behaviour vectorsDBSCAN(eps=0.5, min_samples=5).fit(X)— anomaly detection (outliers labelled −1)- Topic modelling: cluster document embeddings to find thematic groups without predefined topics
- Image compression: K-Means clusters pixel colours → reduce 16M colours to 256 representative centroids
- HDBSCAN on UMAP projections of embeddings — standard pipeline for exploring high-dimensional datasets
Summary
In short: Clustering finds natural groupings in unlabelled data — K-Means for clean spherical clusters, DBSCAN/HDBSCAN for messier real-world shapes.