top of page
K-Means Clustering (78 Pages)

K-Means Clustering (78 Pages)

$39.00Price

You can already ask an AI to write you a K-Means clusterer. The problem is knowing whether its answer is any good — because K-Means always finishes, confidently, with tidy clusters and a neat set of centers, with no way of telling whether that’s the best grouping of your data or just the one its starting guess led it to. Understanding exactly when and why that happens is the foundation under every clustering method you’ll ever use. This is the course that gives you that judgment.


Five parts, one algorithm, no gaps:

  • Part 1 — Intro. How two simple moves — join the nearest center, then move each center to the middle of its group — solve problems from image compression to customer segmentation, and why the same simplicity that makes K-Means fast is exactly what lets it settle for the wrong answer. The intuition before the notation.

  • Part 2 — By Hand. A complete worked example, step by step: ten customer sites, three depots, and a deliberately bad start. Every distance, every assignment and every average is shown as the error falls from 381 to the optimum of 27.17 in four iterations. Then you count all 9,330 possible groupings to prove nothing beats it. Nothing waved away, nothing left “as an exercise.” You prove the algorithm to yourself.

  • Part 3 — In Excel. The same example built out in a live spreadsheet you can open and poke at, so you watch the centers move — and see for yourself how changing one starting point traps the algorithm in a worse answer that looks just as finished.

  • Part 4 — In Python. A clean, executable, verified reference implementation — the known-good version you can check any other code against. It includes k-means++ seeding with restarts, which turns a fragile one-shot run into a genuinely reliable one, and a brute-force check that catches the trap automatically.

  • Part 5 — With AI. A structured prompt template that directs an AI assistant to carry this same algorithm to your problem, plus the understanding to catch it when it’s wrong.


By the end you won’t just have working code. You’ll have followed the algorithm from first principles through a hand calculation, a spreadsheet, and clean Python — so when you point an AI at your own data, you’ll know why the starting centers and the choice of k shape everything, when K-Means is genuinely enough, and when you need to reach for something stronger.


Written for practicing engineers and STEM professionals who’d rather understand a method than trust a black box.

    bottom of page