Learning from examples / 4 of 7
Clustering and distance
What you’ll learn
- Explain the main idea of “Clustering and distance” in your own words.
- Trace a concrete example and identify the assumptions behind it.
- Apply the principle in a practice problem and recognize a common failure.
The idea, intuitively
Clustering groups similar observations. Similarity is a modeling choice: customers may look close by spending but far apart by location. Start by deciding what comparison is meaningful for the task.
Think of the dataset as a sample from a larger environment. A useful model must transfer beyond that sample. Keep training choices separate from final evaluation, and compare against a simple baseline. Before selecting an algorithm, inspect what the labels mean and which errors matter to the user.
Under the hood
K-means alternates assignment to the nearest centroid and updating centroids to group means. It favors roughly spherical clusters under Euclidean distance and needs a chosen number of clusters.
Cluster indices are arbitrary identifiers, not ranked labels.
A worked example
If age ranges from 18 to 80 and income from 0 to 100,000, unscaled income may dominate the distance calculation.
How to use this way of thinking
Define the target, split the data, fit preprocessing only on training examples, and evaluate a baseline. Inspect individual failures alongside aggregate metrics. Change one major choice at a time and use validation evidence to decide whether the additional complexity earns its place.
Try it yourself
Find the centroid of (0,0), (2,0), and (4,3).
Key takeaways
- To prevent numerical units from dominating distances
- Cluster indices are arbitrary identifiers, not ranked labels.
- Check the assumptions with a small example before applying this idea to a larger system.
Check your understanding
Use feedback to learn. Quiz scores and lesson completion are tracked separately.
Go to lesson completionFurther reading
Original papers and reference material for this school. External resources may be in English and require internet access.
Google Machine Learning Crash Course (opens a new tab)scikit-learn user guide (opens a new tab)Finish this lesson
Mark this lesson complete when you’re ready to continue.