← Machine Learning for EveryoneToolsInVisionLearning Center
Unsupervised Patterns · Lesson 58

Run and Inspect K-Means

The team asks k-means to form three route groups.

Read the full lesson and open its transcript below. A narrated video will be added after production.

Lesson overview

What you will learn

The team asks k-means to form three route groups.

  1. A practical question
  2. The useful idea
  3. Work through the example
  4. Limits and next step
01

A practical question

We ask k-means to form three groups of trips. It begins with three centers, assigns each trip to a nearby center, then updates each center from its assigned trips. It repeats until its assignment and center changes settle under the chosen rule.

02

The useful idea

Because centers are means under a squared-distance objective, unusually distant trips can pull them. Different starting centers can produce different final groups. The method tends to favor compact groups in the chosen feature space, even if the real route structure is elongated or nested.

03

Work through the example

Run it several times with different starts. Compare group sizes, representative trips, and whether rainy rural routes stay together. Scale the features intentionally, then show staff the actual examples behind each center. The chosen number of groups and starting centers can change the final grouping. Run the method from several starts, then compare cluster sizes and representative trips. If one group contains almost everything and another contains one unusual record, ask whether that division answers the dispatch question. Scaling also matters: large numeric ranges can control the distance. Keep the input transformation and random seed so another analyst can reproduce the result. Use this case to test your understanding: Run it from different initial centers and inspect cluster sizes. Here is the limitation to watch for: The result depends on scale, chosen k, and assumptions about cluster shape. This supports a careful conclusion: K-means alternates assigning points to centers and updating centers under a squared-distance objective. Try a second random starting point and see whether one unusual route switches groups. If it does, inspect the route and feature scales before treating the color-coded map as a stable structure. Record the seed to make the displayed grouping reproducible.

04

Limits and next step

Next, we'll build a hierarchy that can show smaller route groups inside broader regional ones.

Worked example

Run it from different initial centers and inspect cluster sizes.

Knowledge check

Quick check: test your understanding

Try it yourself: Consider this case: Run it from different initial centers and inspect cluster sizes. Explain how you would check the result. In your answer, address this limitation: The result depends on scale, chosen k, and assumptions about cluster shape.

Check the reasoning

K-means alternates assigning points to centers and updating centers under a squared-distance objective. The result depends on scale, chosen k, and assumptions about cluster shape.

What is the main idea behind run and inspect k-means?

K-means alternates assigning points to centers and updating centers under a squared-distance objective.

How is it used in the example?

Run it from different initial centers and inspect cluster sizes.

What limitation should be checked?

The result depends on scale, chosen k, and assumptions about cluster shape.

Further reading

Machine Learning — Tom M. Mitchell.

Original ToolsInVision teaching examples. Editorial approach · Suggest a correction

Accessible referenceLesson 58 transcript298 words · Narration ready for the upcoming videoOpen transcript

We ask k-means to form three groups of trips. It begins with three centers, assigns each trip to a nearby center, then updates each center from its assigned trips. It repeats until its assignment and center changes settle under the chosen rule.

Because centers are means under a squared-distance objective, unusually distant trips can pull them. Different starting centers can produce different final groups. The method tends to favor compact groups in the chosen feature space, even if the real route structure is elongated or nested.

Run it several times with different starts. Compare group sizes, representative trips, and whether rainy rural routes stay together. Scale the features intentionally, then show staff the actual examples behind each center. The chosen number of groups and starting centers can change the final grouping. Run the method from several starts, then compare cluster sizes and representative trips. If one group contains almost everything and another contains one unusual record, ask whether that division answers the dispatch question. Scaling also matters: large numeric ranges can control the distance. Keep the input transformation and random seed so another analyst can reproduce the result. Use this case to test your understanding: Run it from different initial centers and inspect cluster sizes. Here is the limitation to watch for: The result depends on scale, chosen k, and assumptions about cluster shape. This supports a careful conclusion: K-means alternates assigning points to centers and updating centers under a squared-distance objective. Try a second random starting point and see whether one unusual route switches groups. If it does, inspect the route and feature scales before treating the color-coded map as a stable structure. Record the seed to make the displayed grouping reproducible.

Next, we'll build a hierarchy that can show smaller route groups inside broader regional ones.