AI Clustering Tutorial: K-Means, Dbscan

TL;DRClustering groups similar points without labels — k-means and DBSCAN are the staples.

k-means partitions data into k clusters by repeatedly assigning points to the nearest center and recomputing centers — fast, but you must pick k and it assumes round, similar-sized clusters. DBSCAN groups by density, finding arbitrary shapes and labeling outliers as noise without needing k. Pick by your data's shape and whether you know the cluster count.

Key points

Common mistakes

Try it: Pick k-means or DBSCAN for tight blobs vs irregular shapes with outliers.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>round, known-count clusters → k-means
irregular shapes + outliers → DBSCAN (density)</pre></body></html>
Open the interactive lesson →
Classification vs Regression Dimensionality Reduction · Pca · T-Sne · Umap