Foundations to Frontier
Tests

Bisecting k-Means

Bisecting k-means builds k clusters top-down: start with all the data in one cluster, pick a cluster to split, split it in two with 2-means, and repeat until there are k clusters. It is a divisive hierarchical method. The result is a binary tree of nested clusterings, it costs far less than k-means for large k because each point takes part in only about log k splits, and it is less sensitive to initialisation because each 2-means problem is easy. The choice of which cluster to split matters: largest SSE or largest size. A final round of Lloyd iterations usually polishes the result. This page covers the algorithm, split criteria, cost, the hierarchy, and its use for documents. In the exercises you implement bisecting k-means and check that its clusterings nest; then you compare split criteria, plain k-means++ and bisect-then-refine on equal, unequal-size and unequal-spread blobs.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Split one group at a time

Instead of placing all k centres at once, bisecting k-means starts with everything in one group and keeps cutting:

  1. Pick the group that most needs splitting.
  2. Split it in two with ordinary k-means (k = 2).
  3. Repeat until there are k groups.

Each cut is an easy two-way problem, and the whole history forms a tree: the 5-group answer is the 4-group answer with one group cut in half.

Bisecting k-means: split, split, split
  1. split cluster 1 (397 points, SSE 7707) → 164 + 233
  2. split cluster 1 (164 points, SSE 2025) → 93 + 71
  3. split cluster 2 (233 points, SSE 1251) → 181 + 52
  4. split cluster 2 (181 points, SSE 542) → 73 + 108
  5. split cluster 3 (71 points, SSE 464) → 51 + 20
k = 6 · inertia 959.8
The data has 6 blobs of 220, 90, 40, 20, 15 and 12 points. Splitting by size cuts the big blob twice by k = 6, while small blobs stay merged. Splitting by largest SSE does better (lower inertia), but it still cuts the big blob once: a large, spread-out blob has a large SSE, and the k-means objective rewards splitting it. Every bisecting result is nested: the k-cluster answer refines the (k − 1)-cluster one. Lloyd refinement gives up that nesting but lowers the inertia.
Why engineers care

Bisecting k-means gives a hierarchy for free: coarse operating modes that split into sub-modes, or document topics that split into subtopics. It scales to large k, and it is less fragile than placing many centres at random. scikit-learn ships it as BisectingKMeans.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Bisecting k-means starts with…
  2. 2. Each split uses…
  3. 3. Its clusterings for k and k + 1 are…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Bisecting by hand

Data 0, 1, 10, 11, 12. With one cluster the SSE is 134.8 (mean 6.8).

  1. First split. The best 2-means cut is (0, 1) | (10, 11, 12), with SSE 0.5 + 2 = 2.5.
  2. Choosing the next cluster. By largest SSE, (10, 11, 12) (SSE 2) beats (0, 1) (SSE 0.5). By size it also wins (3 points against 2).
  3. Second split. (10) | (11, 12) or (10, 11) | (12), each SSE 0.5. Total inertia is now 0.5 + 0.5 = 1.

Number of splits. Reaching k clusters takes k − 1 splits. For k = 16 that is 15.

Cost. A split of a cluster with m points costs about m·2·d per 2-means iteration. If splits are balanced, each point takes part in about log₂ k splits, so the total is about n·log₂ k·2d per iteration round, against n·k·d for Lloyd. For k = 1024 that is 10 splits per point against 1024 centres per point.

The steps in plain English:

  1. Put all points in one cluster.
  2. Choose the cluster to split: the largest SSE (most spread out) or the largest size.
  3. Split it with 2-means, trying a few random starts and keeping the lowest SSE.
  4. Repeat 2–3 until there are k clusters. Optionally run Lloyd from the resulting k centres to polish.
📝 Quick check (Level 1)
0/3 answered
  1. 1. SSE of 1, 2, 3?
  2. 2. Splits needed for k = 10?
  3. 3. Balanced splits: how many splits does each point join for k = 1024?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.

Criteria, cost and quality

Which cluster to split?

  • Largest SSE targets the cluster contributing most to the objective. It is the greedy choice for reducing inertia.
  • Largest size is simpler and gives balanced trees, but it keeps splitting big, compact clusters while small, well-separated ones stay merged.

Exercise 2 (blobs of sizes 400 down to 10): splitting by size gave 2.50× the best inertia, against 1.12× for largest-SSE.

Why it is robust. Each 2-means problem has only two centres, so a handful of restarts finds a good split. The typical local-minimum failure of k-means needs several centres in the wrong places at once, and it cannot happen within one split. Exercise 1: on 16 grid blobs, bisecting reached the optimum exactly.

Why it is not optimal. Splits are never undone. A bad early split, or a point stranded on the wrong side, stays wrong. That is why refining with Lloyd from the bisecting centres helps. In exercise 2 it brought every dataset to within 3.1% of the best found.

Hierarchy. The splits form a binary tree. Cutting it at any level gives a valid clustering, and these clusterings are nested. That is a divisive alternative to agglomerative clustering (next topics).

from sklearn.cluster import BisectingKMeans
bkm = BisectingKMeans(n_clusters=8, bisecting_strategy="biggest_inertia", n_init=5, random_state=0).fit(X)
# bisecting_strategy="largest_cluster" splits by size instead
🐍 Exercise 1: bisecting k-means
Implement a best-of-several 2-means split, the largest-SSE (or largest-size) choice of which cluster to split, and the bisecting loop returning the label history; check that the clusterings nest and reach the optimum on grid blobs.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Splitting by size tends to…
  2. 2. Why does Lloyd refinement help after bisecting?
  3. 3. Bisecting k-means is a ____ hierarchical method.

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Greedy objective reduction. Splitting the cluster with the largest SSE does not guarantee the largest reduction in SSE. A cluster with a huge SSE but no gap might gain little from a split. The exact greedy rule computes the best split of every cluster and picks the largest gain, at k times the cost. Largest SSE is a cheap proxy.

Cost. If the splits are roughly balanced, the tree has depth about log₂ k, and the total work per sweep is O(n·d·log k), against O(n·d·k) for Lloyd. This made bisecting k-means attractive for document clustering with large k (Steinbach, Karypis and Kumar, 2000).

Quality guarantees. None in general. Like any greedy divisive method, bisecting can be arbitrarily worse than optimal on adversarial data. In practice it is competitive with, and often better than, single-start k-means.

Inertia versus agreement. Lower inertia does not always mean clusters closer to the truth. In exercise 2, on blobs of unequal spread, the size criterion had worse inertia but slightly higher ARI. The k-means objective prefers splitting a wide blob over separating two tight ones.

Interview questions.

  • When would you use bisecting k-means? With large k, when you want a hierarchy, or when k-means initialisation is unreliable.
  • What is its main weakness? Irrevocable splits. Fix them with Lloyd refinement, and use the SSE criterion with several 2-means trials.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Per-sweep cost of balanced bisecting k-means?
  2. 2. Largest SSE is a proxy for…
  3. 3. Lower inertia always means higher ARI?

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Which split rule, and does refinement matter?

History.

  • M. Steinbach, G. Karypis and V. Kumar (2000) found bisecting k-means as good as or better than k-means and agglomerative methods for document clustering.
  • S. Savaresi and D. Boley (2004) analysed bisecting k-means against principal-direction divisive partitioning.
  • scikit-learn added BisectingKMeans in version 1.1 (2022).

Exercise 2. Six datasets of each kind, k equal to the true number of blobs. Each cell shows inertia ÷ the best of the four methods, then ARI with the true labels.

data bisect, largest SSE bisect, largest size k-means++ (1 start) bisect SSE + Lloyd
12 equal blobs 1.120, 0.901 1.137, 0.907 1.434, 0.808 1.031, 0.921
8 blobs, sizes 400…10 1.122, 0.657 2.502, 0.476 1.214, 0.648 1.001, 0.669
8 blobs, spreads 3…0.3 1.169, 0.745 1.358, 0.776 1.118, 0.740 1.001, 0.757
  • Bisect, then refine, was best by inertia on every kind of data.
  • Plain bisecting beat single-start k-means++ on equal blobs (1.12 against 1.43), where random seeding most often doubles up.
  • Splitting by size failed on unequal sizes: it kept cutting the 400-point blob.
  • Unequal sizes are hard for every k-means variant (ARI about 0.65), because the objective prefers to split big blobs rather than isolate tiny ones.
🐍 Exercise 2 (research): split rules and refinement
On equal, unequal-size and unequal-spread blob datasets, compare bisecting with the largest-SSE and largest-size rules, single-start k-means++, and bisecting followed by Lloyd: mean inertia relative to the best and ARI with the truth.

Bisecting k-means in AI, robotics and aerospace

  • Topic hierarchies for maintenance logs and reports: broad failure categories that split into specific modes.
  • Hierarchical codebooks and vocabulary trees (Nistér and Stewénius, 2006) for fast visual place recognition, built by recursive k-means splits.
  • Large-k quantisation of telemetry or embeddings, where flat k-means is too slow.

References

  1. M. Steinbach, G. Karypis, V. Kumar (2000). “A comparison of document clustering techniques.” KDD Workshop on Text Mining.
  2. S. M. Savaresi, D. L. Boley (2004). “A comparative analysis on the bisecting K-means and the PDDP clustering algorithms.” Intelligent Data Analysis 8(4).
  3. D. Nistér, H. Stewénius (2006). “Scalable recognition with a vocabulary tree.” Proc. CVPR.
  4. D. Boley (1998). “Principal direction divisive partitioning.” Data Mining and Knowledge Discovery 2.
  5. scikit-learn developers. “BisectingKMeans.” Documentation.