Art of DS

Appearance

Palette
Theme
Unlock $20 one time
Sign in, or create an account

Sign in to Art of DSCreate your Art of DS account

We email you a link and a six-digit code. Either one signs you in; there is no password.Enter your email. We send a link and a six-digit code to confirm it — no password to remember. The account is free.

  • You come back to this page, right where you were.
  • Already have an account? The same email simply signs you in.

By continuing you accept the Terms and the Privacy policy.

Your account

Free accountLifetime access

Machine learning · 7 compared

Clustering methods

Definition

Read the "Shape it can find" column first. Every method here partitions whatever it is given, so the choice is not which is best but which one's idea of a cluster matches yours.

Comparison

Name What defines a cluster Shape it can find Number of clusters Outliers New points
K-means Points nearer to this centre than to any other. Minimises within-cluster squared distance, which is why it wants convex, similarly-sized, similarly-dense blobs. Full page →convex and isotropicyou chooseabsorbed, and they move the centreassign to nearest centre
Bisecting k-means Repeatedly split the worst cluster in two with k-means. Same objective, built top-down, and it cannot leave a cluster empty.convex and isotropicyou chooseabsorbedassign to nearest centre
Gaussian mixture Points generated by this Gaussian rather than that one. K-means is the special case where every component is a small sphere of equal size.ellipsoidal, any orientationyou chooseabsorbed, with low likelihoodscore under each component
Ward / agglomerative Merge the two nearest clusters, over and over, and read the tree. The linkage rule is the whole method — Ward merges to keep within-cluster variance low.depends on linkagecut the tree anywheremerged in eventuallyrefit
Spectral Embed the affinity graph with its leading eigenvectors, then cluster that. Works on connectivity rather than distance, so it can follow a curved shape.non-flat, connectedyou chooseabsorbedrefit
DBSCAN A dense region, grown from core points that have enough neighbours within a radius. Anything not reachable from a core point is not in any cluster.any, if density is evenfound, not chosenlabelled as noiserefit
HDBSCAN DBSCAN across every radius at once, keeping the clusters that persist. Removes the single hardest parameter to set and handles clusters of differing density.any, density may varyfound, not chosenlabelled as noiserefit

Clustering has no right answer to check against, so the usual way of choosing a method — try several, keep the best score — does not apply. What replaces it is the first column: each of these algorithms encodes a different idea of what a cluster is, and the useful question is which idea matches the thing you are looking for.

The split that matters most is flat against non-flat

K-means, bisecting k-means and Gaussian mixtures assume clusters are blobs. They differ in how flexible the blob is — a mixture model fits ellipses at any orientation, and "KMeans can be seen as a special case of Gaussian mixture model with equal covariance per component" [1, §2.3.1] — but all of them are asking "which centre is this nearest to?".

The cost of that assumption is precise. K-means' objective "makes the assumption that clusters are convex and isotropic" and "responds poorly to elongated clusters, or manifolds with irregular shapes" [1, §2.3.2].

DBSCAN, HDBSCAN and spectral clustering do not. DBSCAN "views clusters as areas of high density separated by areas of low density", and "due to this rather generic view, clusters found by DBSCAN can be any shape, as opposed to k-means which assumes that clusters are convex shaped" [1, §2.3.7]. Spectral clustering gets there differently, by embedding an affinity matrix and clustering the eigenvectors [1, §2.3.5], which makes connectivity rather than distance the criterion.

Non-flat methods are the answer "when the clusters have a specific shape, i.e. a non-flat manifold, and the standard euclidean distance is not the right metric" [1, §2.3.1].

Two columns nobody reads until it is too late

Outliers. Only the density methods have a category for "this point is not in any cluster". Everything else assigns every point somewhere, and in k-means a single distant point drags a centre towards it. If your data has junk in it, that is a decision the algorithm is making on your behalf.

New points. The documentation's word for this is inductive versus transductive, and the distinction is operational: transductive methods "are not designed to be applied to new, unseen data" [1, §2.3.1]. K-means and mixtures can label a new point in microseconds. DBSCAN, spectral and agglomerative clustering cannot — you refit. For anything that has to run in production on arriving data, that column decides the choice on its own.

Hierarchical methods answer a different question

Agglomerative clustering "build[s] nested clusters by merging or splitting them successively", represented "as a tree (or dendrogram)" whose root holds everything and whose leaves are single samples [1, §2.3.6]. You do not have to choose k in advance; you choose where to cut afterwards, having seen the structure.

Ward linkage is the one to know, because it is k-means' objective reached by a different route: it "minimizes the sum of squared differences within all clusters. It is a variance-minimizing approach and in this sense is similar to the k-means objective function but tackled with an agglomerative hierarchical approach" [1, §2.3.6].

Which to reach for

Start with k-means if you expect blobs and have a lot of data — with D²-sampling for the seeds and several restarts, since a single run from random points lands badly far more often than not [2, §3.1]. See k-means for how often.

Switch to HDBSCAN when you do not know k, when the shapes are irregular, or when some points should be allowed to belong to nothing. It handles "variable cluster density" [1, §2.3.1], which is the parameter that makes plain DBSCAN hard to tune.

Use a Gaussian mixture when you want probabilities rather than hard labels, or when clusters are elongated in different directions.

Use agglomerative clustering when the hierarchy is the point — taxonomies, nested segments, anything where "how many groups?" is the question rather than the input [1, §2.3.6].

Use spectral clustering for a small number of connected, curved clusters. It "works well for a small number of clusters, but is not advised for many" [1, §2.3.5].

One caution for every row. None of these methods can tell you whether the structure it found is real. They partition data drawn from a single blob just as willingly as data with genuine groups, and the output looks identical. Whatever you get here is a hypothesis to be tested against something outside the clustering itself.

Sources

  1. scikit-learn User Guide — Clusteringdocs · retrieved 2026-09-06https://scikit-learn.org/stable/modules/clustering.html
  2. Blömer, Lammersen, Schmidt, Sohler. Theoretical Analysis of the k-Means Algorithm — A Survey (2016)paperhttps://ar5iv.labs.arxiv.org/html/1602.08254

Have a promo code?

A code that takes 100% off unlocks everything at once. A smaller one takes its share off the price in the payment window: enter the same code there.

Write to support

A question, a problem with access, a refund? Write to us and we answer by email.

What is it about?

Your address is used only to answer you.

Message sent

Thank you. We will reply to the address you gave, by email.

Or write to us directly

support@artofds.com

Message sent Thank you. We will reply to the address you gave, by email.

Check the email address: we need it to reply.

That is our own address. Enter yours, so the reply reaches you.

This address cannot receive email. Check it for a typo.

Write a little more: at least 10 characters.

Too many messages in a short time. Try again in a few minutes.

The message could not be sent. Please write to us directly: support@artofds.com