CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Artificial Intelligence / Learning From Data

Finding Groups: Clustering

Lesson 8 of 11 · 7 min · Free, no account needed

What you will learn

  • Clustering finds groups in data that has no labels: unsupervised learning.
  • k-means: colour each point by its nearest centre, move each centre to the mean of its points, repeat.
  • You choose k. A bad start can get stuck, so real tools try several starts.

Start the lesson

How the lesson goes

  1. A music app has never asked what you like. How can it already sort listeners into groups?

    Each dot is a listener, placed by the songs they play. Tap one listener in each group you see, then Check.

  2. Drop three flags.

    Drag the flags onto the map. Every listener takes the colour of its nearest flag.

  3. Now let the flags move themselves.

    Step 1 colours every dot by its nearest flag. Step 2 moves each flag to the centre of its dots. Repeat until nothing changes.

  4. You just ran a famous algorithm.

    Tap to reveal its name.

    Finding groups in data is clustering.

    k-means: drop k centres, colour each point by its nearest centre, move each centre to the mean of its points, repeat until nothing changes.

    No labels were used. Learning without answers is unsupervised learning. You only choose k, how many groups.

  5. Where will the blue flag move?

    Drag the dashed ring to the centre of the blue points. Then Check.

  6. A bad start gets k-means stuck.

    Two flags start in the same group, one sits between the other two. Run it and see. Then move the flags and run again until each group gets its own flag. Then Check.

  7. Settle in one.

    Place the three flags so well that one Step barely moves them. Three stars: no flag moves more than 0.4.

  8. Math: the centre of three points is their mean.

    A flag owns the points (2, 4), (4, 8) and (6, 3). Its new spot across is (2 + 4 + 6) / 3 = 4. What is its new spot up?

  9. Which tasks need labels?

    Drag each task to a machine, or tap it and then a machine. Then Check.

  10. Your flags, new listeners.

    Your flags from Settle in one meet 42 new listeners. Press Run to the end, then tap each flag to name its group.

Previous lesson: Scale Your Features · Next lesson: Biased Data, Biased Machine · Part of the course: Learning From Data

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab