# K-Means, Its Failure Modes, and Gaussian Mixture Models

> A practical visual treatment of clustering for working data analysts. The lecture runs k-means from initialization through nearest-centre assignment, mean updates, repetition, and convergence, then tests the method against unlucky starts, elongated groups, unequal cluster sizes, and an imposed value of k. Soft responsibilities lead naturally to Gaussian mixtures, where component weights, means, and covariance matrices model population share, location, spread, elongation, and orientation. The closing workflow emphasizes restarts, scaling, stability, model selection, and domain validation.

- Canonical watch page: [K-Means, Its Failure Modes, and Gaussian Mixture Models](https://academa.ai/lectures/clustering-k-means-and-where-it-fails)
- Publisher: [Academa, Inc.](https://academa.ai)
- Subject: Machine Learning
- Published: 2026-08-28T22:51:23.000Z
- Updated: 2026-08-28T22:51:23.000Z
- Duration: PT823S (13 minutes 43 seconds)
- Chapters: 6
- Views: 0
- Language: en-US
- Access: Free
- Video stream: [HLS content](https://academa.ai/media/l/01M14TYKN0KG2QE2M697DD03FR/0/dark/master.m3u8)
- Audiovisual record: [Semantic JSON](https://academa.ai/media/l/01M14TYKN0KG2QE2M697DD03FR/0/semantic.json)
- Thumbnail: [Image](https://academa.ai/media/l/01M14TYKN0KG2QE2M697DD03FR/0/dark/poster.jpg)

## Description

A practical visual guide to k-means iteration, its key failure modes, soft membership, and Gaussian mixtures with learned covariance.

## Chapters

- [00:00–01:35.014 · Two Kinds of Membership](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=0)
- [01:35.014–04:2.111 · Run K-Means](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=95.01412499999999)
- [04:2.111–05:49.139 · Initialization Changes the Answer](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=242.11149999999998)
- [05:49.139–08:7.93 · Geometry and Forced Clusters](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=349.1395)
- [08:7.93–11:22.489 · From Soft Membership to Mixtures](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994)
- [11:22.489–13:43 · Choose and Check](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666)

## Transcript

### [00:00 · Two Kinds of Membership](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=0)

Clustering looks for useful groups when the data has no group label. K-means is often the first method an analyst tries because its loop is fast, concrete, and easy to inspect. But its answer contains assumptions. Today we will run that loop, break those assumptions on purpose, and then see what a Gaussian mixture adds. Think of each dot as one row of a data set and each axis as one measured feature. Clustering asks whether rows that sit near one another should be treated as members of the same group. K-means gives a hard answer. Each observation belongs to exactly one cluster, represented by one centre. The rule is simply: choose the nearest centre. A Gaussian mixture can give a softer answer. Instead of one cluster label, it gives one probability for every component. Those probabilities express uncertainty about observations near an overlap. That distinction matters operationally. A hard label is convenient for routing or summarizing records. A probability is useful when a borderline case should remain borderline rather than being forced across a sharp boundary. We will not treat the more flexible model as automatically better. K-means has fewer parameters and is often exactly the right baseline. The point is to know what geometry it can represent, what failures to expect, and when extra probability and covariance parameters have a real job to do.

### [01:35.014 · Run K-Means](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=95.01412499999999)

Here is our concrete problem. We have twelve observations, two features, and a requested value k equals two. The algorithm must return two clusters. First put the data on the plane. At this stage the points have no fitted cluster identity. K-means needs starting centres. These two are deliberately away from the middle of the groups. They are guesses, not observations and not yet fitted means. The assignment step examines every observation. For each centre, compute squared Euclidean distance across the features, then give the observation to the centre with the smaller total. After that comparison, these six points belong to the red centre and these six belong to the green centre. The colour is the hard cluster label z. Now freeze the assignments and update one centre at a time. The new red centre is the coordinate-wise mean of the six red observations. The green centre is calculated in exactly the same way from the green observations. A centre is therefore a fitted average, not necessarily a row that actually occurs in the data. Move both centres to those means. As the centres travel, the assigned observations stay fixed. When the centres arrive, one full k-means pass is complete. Then repeat. With the centres in their new positions, calculate every nearest-centre assignment again. In this example every point keeps its colour. Recomputing the two means therefore returns the same two centres. The second pass changes neither the assignments nor the centres. That is convergence. Implementations may stop when assignments are identical, when centre movement is below a tolerance, or when a maximum iteration count is reached. The loop is alternating optimization. With centres fixed, nearest-centre assignment cannot increase the within-cluster sum of squares. With assignments fixed, replacing each centre by its mean cannot increase it either. So the objective falls or stays level on every pass. Because only finitely many hard assignments exist, the procedure eventually stops. What this does not prove is that it found the best possible clustering. It may have stopped at a merely local solution.

### [04:2.111 · Initialization Changes the Answer](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=242.11149999999998)

K-means can finish at different answers on the same data because its objective is not generally convex in all assignments and centres together. Here are two runs with k equal to three. On the left, the starting centres are spread across the visible groups. On the right, an unlucky draw crowds all three starting centres into the left-hand group. Run the same assignment and update loop on both sides. The favourable start settles with one centre in each visible group. The unlucky run spends two centres splitting the left group. Its remaining centre absorbs both right-hand groups, even though they are visibly separated. Another pass changes neither answer. Both are local solutions, but the right-hand solution has a larger within-cluster sum of squares and a much less useful interpretation. The practical remedy is not to trust one random start. K-means++ spreads seeds by favouring observations far from centres already chosen. It reduces bad starts, but does not abolish local minima. For routine analysis, make initialization part of the specification. Use a dispersed seeding rule, then run many independent starts. Retain the run with the lowest objective, but still inspect its groups. A numerical improvement can be immaterial, and several nearly tied runs can imply genuine ambiguity in the data. Record the number of starts, the random seed, and the spread of objective values. Reproducibility here is not clerical detail. It is evidence about how strongly the data supports the fitted partition.

### [05:49.139 · Geometry and Forced Clusters](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=349.1395)

The nearest-centre rule creates Voronoi cells: regions separated by straight boundaries. That simple geometry explains several important failures. First, consider two long natural groups. Their gray outlines run diagonally across the feature space. With these fitted centres, nearest-centre assignment makes a nearly vertical cut. Red and green divide both long groups across their length rather than following the two elongated densities. K-means has a centre for location, but no parameter for orientation or different spread in different directions. Squared Euclidean distance therefore prefers compact, roughly spherical clusters. Second, place one small dense cluster beside one large diffuse cluster. The gray circles show the intended populations. The large group contributes many more squared distances to the objective. A centre can reduce that cost by moving toward it, while the boundary gives part of the large group to the small cluster. The result is mathematically consistent with the objective, but unfair to the smaller group as a density. K-means does not model cluster population or variance separately. Third, this is one connected cloud without three clear density peaks. We nevertheless request k equals three. K-means does not answer that the data contains one group. It returns exactly three nonempty partitions because three centres were requested. This is not a software defect. The value k is an input to the problem, not a conclusion reached by the algorithm. A tidy colour map does not prove that the corresponding groups exist. Before believing a k-means result, ask whether compact clusters are plausible in the scaled feature space, and whether their spreads and populations are comparable. Then test stability across initializations and resampled data. Finally, ask what k means in the business or scientific setting. If it has no interpretation, treat it as a modelling choice to validate, not a fact discovered by the colours.

### [08:7.93 · From Soft Membership to Mixtures](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994)

To relax hard assignment, keep one membership number for every component. For observation i and component j, call that number the responsibility r i j. Consider this observation near the overlap. A hard rule must choose one side. The mixture instead evaluates how plausible the observation is under both fitted components. Suppose the resulting responsibilities are zero point three five and zero point six five. The second component is more plausible, but the first remains credible. The two values add to one. These are model-based probabilities, not calibrated truth supplied by the data. They depend on the fitted component shapes, their population weights, and the Gaussian mixture assumptions. A Gaussian mixture says that the observed density is a weighted sum of Gaussian component densities. The extra parameters each answer a distinct question. The mixture weight pi records the expected share of observations generated by a component. Unlike k-means, the model can explicitly represent one large component and one small component. The mean mu gives location, much like a k-means centre. Here the two means sit near the middle of their respective densities. The covariance matrix Sigma is the crucial addition. Its overall scale controls spread. Its unequal directional variances create elongation, and its off-diagonal relationship rotates that elongation. These ellipses are equal-density contours. They can follow the long axes of the two groups, which is exactly the geometric freedom missing from nearest-centre k-means. The usual fitting procedure alternates two weighted steps. In the E step, use the current weights, means, and covariances to compute every responsibility. In the M step, treat those responsibilities as fractional counts. Update each mixture weight from its total responsibility. Update each mean as a responsibility-weighted average. Then update each covariance from weighted deviations around that mean. Repeat the two steps until log likelihood no longer improves materially. Like k-means, this alternating fit can reach local optima, so restarts still matter. Return to the elongated example. On the left, k-means uses a straight nearest-centre boundary and slices across both natural groups. On the right, the Gaussian mixture learns two covariance ellipses. Their orientations follow the groups, and observations in the overlap can retain intermediate responsibilities instead of being treated as certain. The gain is real, but so is the cost. More parameters require more data, covariance estimates can become unstable, and a Gaussian component can chase a tiny group unless the fit is regularized and checked.

### [11:22.489 · Choose and Check](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666)

K-means and Gaussian mixtures answer related but different modelling questions. K-means asks for a hard partition that minimizes squared distance to centres. A Gaussian mixture asks for a probability density assembled from weighted components. It returns probabilistic membership and can learn a different covariance shape for every component. Choose k-means when a fast, interpretable hard partition is useful and compact groups are plausible after sensible scaling. Choose a Gaussian mixture when overlap, unequal populations, or elliptical covariance structure is part of the question. Neither model determines the scientifically correct number of groups by itself. K-means returns the k requested. A mixture with k components also fits the requested count, even if some fitted components become tiny or redundant. A defensible workflow begins before fitting. Scale features according to what distance should mean, then use several starts and check whether the result is stable. Compare several credible values of k. For k-means, inspect objective curves and resampling stability. For mixtures, likelihood criteria such as B I C can help penalize unnecessary parameters, but none of these replaces domain judgment. Inspect the fitted objects themselves. Look for clusters created only by one scale, uncertain responsibilities, tiny components, extreme covariance estimates, and solutions that change sharply across restarts. Finally, judge the clustering by the decision it supports. A useful segment, anomaly group, or population subtype must remain interpretable and stable where it will actually be used. The durable lesson is simple. K-means alternates nearest-centre assignment with mean updates, and that simplicity creates both its speed and its geometric limits. Gaussian mixtures replace certainty with responsibilities and add weights and covariance, but those extra freedoms deserve validation because they can fit both real structure and noise.

## About Academa, Inc.

Academa makes technical knowledge easier to understand through visual lectures and lets learners request new lecture videos on the topics they need.

## Complete audiovisual record

Immutable source: [semantic.json](https://academa.ai/media/l/01M14TYKN0KG2QE2M697DD03FR/0/semantic.json)

Record version: 1. Render attempt: 0.

### How to read this timeline

Each scene owns its object identifiers. A beat's board is the complete board when listed, empty when marked empty, and unchanged from the nearest earlier listed board in the same scene when marked unchanged. Action times are absolute positions in the published video.

### Scene 1: [Two Kinds of Membership](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=0)

Span: 00:00–01:35.014 (0s–95.01412499999999s).

#### Objects

- ambiguous: a Point \[yellow\] labelled "x\_i" drawn in scatter (location=(0.1, 0.2))
- card: a Title that says "Practical Unsupervised Learning — K-Means, Its Failure Modes, and Gaussian Mixture Models"
- centre\_1: a Point \[red\] labelled "mu\_1" drawn in scatter (location=(-2.2, 0.1))
- centre\_2: a Point \[green\] labelled "mu\_2" drawn in scatter (location=(2.1, 0.0))
- hard\_rule: a Math \[text\] that says "$upright("k-means:") thin x\_i arrow.r upright("one nearest centre")$"
- heading: a Heading that says "What Does It Mean to Belong?"
- left\_points: a Point \[red\] drawn in scatter (location=(-3.1, -0.2))
- left\_points\_2: a Point \[red\] drawn in scatter (location=(-2.8, 0.7))
- left\_points\_3: a Point \[red\] drawn in scatter (location=(-2.4, -0.8))
- left\_points\_4: a Point \[red\] drawn in scatter (location=(-2.0, 0.3))
- left\_points\_5: a Point \[red\] drawn in scatter (location=(-1.6, 1.0))
- left\_points\_6: a Point \[red\] drawn in scatter (location=(-1.2, -0.4))
- question: a Panel that says "Given only feature measurements, which observations form useful groups?"
- right\_points: a Point \[green\] drawn in scatter (location=(1.0, 0.3))
- right\_points\_2: a Point \[green\] drawn in scatter (location=(1.5, -0.8))
- right\_points\_3: a Point \[green\] drawn in scatter (location=(1.9, 0.9))
- right\_points\_4: a Point \[green\] drawn in scatter (location=(2.4, -0.1))
- right\_points\_5: a Point \[green\] drawn in scatter (location=(2.8, 0.7))
- right\_points\_6: a Point \[green\] drawn in scatter (location=(3.1, -0.7))
- scatter: an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False)
- soft\_definition: a Panel that says "A responsibility $r\_(i j)$ is the fitted probability that observation $i$ belongs to component $j$. For one observation, the responsibilities add to one."
- soft\_rule: a Math \[text\] that says "$upright("mixture:") thin x\_i arrow.r (r\_(i 1), dots, r\_(i k))$"
- to\_first: a Line \[gray\] drawn in scatter (start=(0.1, 0.2), end=(-2.2, 0.1), dashed=True)
- to\_second: a Line \[gray\] drawn in scatter (start=(0.1, 0.2), end=(2.1, 0.0), dashed=True)

#### Beats

##### [00:00](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=0)

Narration: Clustering looks for useful groups when the data has no group label. K-means is often the first method an analyst tries because its loop is fast, concrete, and easy to inspect. But its answer contains assumptions. Today we will run that loop, break those assumptions on purpose, and then see what a Gaussian mixture adds.

Board: Empty.

Actions:
- [00:00](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=0): card is shown on the screen, written out.
- [00:1.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=1.5): card: enter:write-left-to-right.
- [00:20.77](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=20.77): card is hidden from the screen — left the board.

##### [00:21.97](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=21.97)

Narration: Think of each dot as one row of a data set and each axis as one measured feature. Clustering asks whether rows that sit near one another should be treated as members of the same group.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [00:21.97](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=21.97): heading is shown on the screen, written out.
- [00:21.97](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=21.97): question is shown on the screen, written out.
- [00:22.933](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=22.933): scatter is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points\_2 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points\_3 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points\_4 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points\_5 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): left\_points\_6 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points\_2 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points\_3 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points\_4 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points\_5 is shown on the screen, written out.
- [00:29.365](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=29.365): right\_points\_6 is shown on the screen, written out.

##### [00:34.343](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=34.3425)

Narration: K-means gives a hard answer. Each observation belongs to exactly one cluster, represented by one centre. The rule is simply: choose the nearest centre.

Board: question — a Panel that says "Given only feature measurements, which observations form useful groups?"; scatter — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); heading — a Heading that says "What Does It Mean to Belong?"; left\_points — a Point \[red\] drawn in scatter (location=(-3.1, -0.2)); left\_points\_2 — a Point \[red\] drawn in scatter (location=(-2.8, 0.7)); left\_points\_3 — a Point \[red\] drawn in scatter (location=(-2.4, -0.8)); left\_points\_4 — a Point \[red\] drawn in scatter (location=(-2.0, 0.3)); left\_points\_5 — a Point \[red\] drawn in scatter (location=(-1.6, 1.0)); left\_points\_6 — a Point \[red\] drawn in scatter (location=(-1.2, -0.4)); right\_points — a Point \[green\] drawn in scatter (location=(1.0, 0.3)); right\_points\_2 — a Point \[green\] drawn in scatter (location=(1.5, -0.8)); right\_points\_3 — a Point \[green\] drawn in scatter (location=(1.9, 0.9)); right\_points\_4 — a Point \[green\] drawn in scatter (location=(2.4, -0.1)); right\_points\_5 — a Point \[green\] drawn in scatter (location=(2.8, 0.7)); right\_points\_6 — a Point \[green\] drawn in scatter (location=(3.1, -0.7))

Actions:
- [00:41.099](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=41.099000000000004): centre\_1 is shown on the screen, written out.
- [00:41.099](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=41.099000000000004): centre\_2 is shown on the screen, written out.
- [00:44.188](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=44.18800000000001): hard\_rule is shown on the screen, written out.
- [00:44.188](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=44.18800000000001): hard\_rule (the "upright("one nearest centre")" part) is emphasized.
- [00:45.383](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=45.3835): hard\_rule (the "upright("one nearest centre")" part) is no longer emphasized.

##### [00:45.983](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=45.9835)

Narration: A Gaussian mixture can give a softer answer. Instead of one cluster label, it gives one probability for every component. Those probabilities express uncertainty about observations near an overlap.

Board: question — a Panel that says "Given only feature measurements, which observations form useful groups?"; hard\_rule — a Math \[text\] that says "$upright("k-means:") thin x\_i arrow.r upright("one nearest centre")$"; scatter — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); heading — a Heading that says "What Does It Mean to Belong?"; left\_points — a Point \[red\] drawn in scatter (location=(-3.1, -0.2)); left\_points\_2 — a Point \[red\] drawn in scatter (location=(-2.8, 0.7)); left\_points\_3 — a Point \[red\] drawn in scatter (location=(-2.4, -0.8)); left\_points\_4 — a Point \[red\] drawn in scatter (location=(-2.0, 0.3)); left\_points\_5 — a Point \[red\] drawn in scatter (location=(-1.6, 1.0)); left\_points\_6 — a Point \[red\] drawn in scatter (location=(-1.2, -0.4)); right\_points — a Point \[green\] drawn in scatter (location=(1.0, 0.3)); right\_points\_2 — a Point \[green\] drawn in scatter (location=(1.5, -0.8)); right\_points\_3 — a Point \[green\] drawn in scatter (location=(1.9, 0.9)); right\_points\_4 — a Point \[green\] drawn in scatter (location=(2.4, -0.1)); right\_points\_5 — a Point \[green\] drawn in scatter (location=(2.8, 0.7)); right\_points\_6 — a Point \[green\] drawn in scatter (location=(3.1, -0.7)); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in scatter (location=(-2.2, 0.1)); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in scatter (location=(2.1, 0.0))

Actions:
- [00:47.701](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=47.701): hard\_rule is hidden from the screen — left the board.
- [00:47.701](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=47.701): question is hidden from the screen — left the board.
- [00:47.701](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=47.701): soft\_rule is shown on the screen, written out.
- [00:52.02](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=52.019999999999996): soft\_definition is shown on the screen, written out.
- [00:56.699](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=56.699): ambiguous is shown on the screen, written out.
- [00:57.79](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=57.79): to\_first is shown on the screen, written out.
- [00:57.79](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=57.79): to\_second is shown on the screen, written out.

##### [00:59.284](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=59.284)

Narration: That distinction matters operationally. A hard label is convenient for routing or summarizing records. A probability is useful when a borderline case should remain borderline rather than being forced across a sharp boundary.

Board: soft\_rule — a Math \[text\] that says "$upright("mixture:") thin x\_i arrow.r (r\_(i 1), dots, r\_(i k))$"; scatter — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); heading — a Heading that says "What Does It Mean to Belong?"; left\_points — a Point \[red\] drawn in scatter (location=(-3.1, -0.2)); left\_points\_2 — a Point \[red\] drawn in scatter (location=(-2.8, 0.7)); left\_points\_3 — a Point \[red\] drawn in scatter (location=(-2.4, -0.8)); left\_points\_4 — a Point \[red\] drawn in scatter (location=(-2.0, 0.3)); left\_points\_5 — a Point \[red\] drawn in scatter (location=(-1.6, 1.0)); left\_points\_6 — a Point \[red\] drawn in scatter (location=(-1.2, -0.4)); right\_points — a Point \[green\] drawn in scatter (location=(1.0, 0.3)); right\_points\_2 — a Point \[green\] drawn in scatter (location=(1.5, -0.8)); right\_points\_3 — a Point \[green\] drawn in scatter (location=(1.9, 0.9)); right\_points\_4 — a Point \[green\] drawn in scatter (location=(2.4, -0.1)); right\_points\_5 — a Point \[green\] drawn in scatter (location=(2.8, 0.7)); right\_points\_6 — a Point \[green\] drawn in scatter (location=(3.1, -0.7)); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in scatter (location=(-2.2, 0.1)); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in scatter (location=(2.1, 0.0)); soft\_definition — a Panel that says "A responsibility $r\_(i j)$ is the fitted probability that observation $i$ belongs to component $j$. For one observation, the responsibilities add to one."; ambiguous — a Point \[yellow\] labelled "x\_i" drawn in scatter (location=(0.1, 0.2)); to\_first — a Line \[gray\] drawn in scatter (start=(0.1, 0.2), end=(-2.2, 0.1), dashed=True); to\_second — a Line \[gray\] drawn in scatter (start=(0.1, 0.2), end=(2.1, 0.0), dashed=True)

Actions:
- [01:8.213](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=68.213): ambiguous is indicated — a transient flash.

##### [01:13.805](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=73.80499999999999)

Narration: We will not treat the more flexible model as automatically better. K-means has fewer parameters and is often exactly the right baseline. The point is to know what geometry it can represent, what failures to expect, and when extra probability and covariance parameters have a real job to do.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [01:18.193](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=78.193): centre\_1 is indicated — a transient flash.
- [01:18.393](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=78.393): centre\_2 is indicated — a transient flash.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): heading is hidden from the screen — left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): scatter is hidden from the screen — left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points\_2 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points\_3 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points\_4 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points\_5 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): left\_points\_6 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points\_2 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points\_3 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points\_4 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points\_5 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): right\_points\_6 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): centre\_1 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): centre\_2 is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): ambiguous is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): to\_first is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): to\_second is hidden from the screen — scatter left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): soft\_definition is hidden from the screen — left the board.
- [01:33.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=93.97245833333332): soft\_rule is hidden from the screen — left the board.

### Scene 2: [Run K-Means](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=95.01412499999999)

Span: 01:35.014–04:2.111 (95.01412499999999s–242.11149999999998s).

#### Objects

- assign\_rule: a Math \[text\] that says "$z\_i = op("arg min")\_j sum\_l (x\_(i l) - mu\_(j l))^2$"
- assigned\_a: a Point \[red\] drawn in plot (location=(-3.2, 1.0))
- assigned\_a\_2: a Point \[red\] drawn in plot (location=(-2.8, 1.5))
- assigned\_a\_3: a Point \[red\] drawn in plot (location=(-2.5, 0.8))
- assigned\_a\_4: a Point \[red\] drawn in plot (location=(-3.4, 0.2))
- assigned\_a\_5: a Point \[red\] drawn in plot (location=(-2.7, 0.0))
- assigned\_a\_6: a Point \[red\] drawn in plot (location=(-2.0, 1.1))
- assigned\_b: a Point \[green\] drawn in plot (location=(1.5, -1.0))
- assigned\_b\_2: a Point \[green\] drawn in plot (location=(2.1, -1.4))
- assigned\_b\_3: a Point \[green\] drawn in plot (location=(2.8, -0.7))
- assigned\_b\_4: a Point \[green\] drawn in plot (location=(1.9, -0.2))
- assigned\_b\_5: a Point \[green\] drawn in plot (location=(3.2, -1.5))
- assigned\_b\_6: a Point \[green\] drawn in plot (location=(2.7, 0.1))
- centre\_1: a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11)
- centre\_1\_x: a VariableNumber (initial\_value=-3.5)
- centre\_1\_y: a VariableNumber (initial\_value=-1.5)
- centre\_2: a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11)
- centre\_2\_x: a VariableNumber (initial\_value=3.5)
- centre\_2\_y: a VariableNumber (initial\_value=1.5)
- history: a Table \[text\] that says "Pass Assignments Centres 1 red or green move 2 unchanged unchanged" (rows=(('Pass', 'Assignments', 'Centres'), ('1', 'red or green', 'mov…, header=True)
- mean\_1: a Point \[yellow\] labelled "overline(x)\_1" drawn in plot (location=(-2.7666666667, 0.7666666667))
- mean\_2: a Point \[yellow\] labelled "overline(x)\_2" drawn in plot (location=(2.3666666667, -0.7833333333))
- move\_1: a Vector \[yellow\] drawn in plot (start=(-3.5, -1.5), end=(-2.7666666667, 0.7666666667))
- move\_2: a Vector \[yellow\] drawn in plot (start=(3.5, 1.5), end=(2.3666666667, -0.7833333333))
- neutral\_points: a Point \[gray\] drawn in plot (location=(-3.2, 1.0))
- neutral\_points\_10: a Point \[gray\] drawn in plot (location=(1.9, -0.2))
- neutral\_points\_11: a Point \[gray\] drawn in plot (location=(3.2, -1.5))
- neutral\_points\_12: a Point \[gray\] drawn in plot (location=(2.7, 0.1))
- neutral\_points\_2: a Point \[gray\] drawn in plot (location=(-2.8, 1.5))
- neutral\_points\_3: a Point \[gray\] drawn in plot (location=(-2.5, 0.8))
- neutral\_points\_4: a Point \[gray\] drawn in plot (location=(-3.4, 0.2))
- neutral\_points\_5: a Point \[gray\] drawn in plot (location=(-2.7, 0.0))
- neutral\_points\_6: a Point \[gray\] drawn in plot (location=(-2.0, 1.1))
- neutral\_points\_7: a Point \[gray\] drawn in plot (location=(1.5, -1.0))
- neutral\_points\_8: a Point \[gray\] drawn in plot (location=(2.1, -1.4))
- neutral\_points\_9: a Point \[gray\] drawn in plot (location=(2.8, -0.7))
- objective: a Math \[text\] that says "$J = sum\_i sum\_l (x\_(i l) - mu\_(z\_i l))^2$"
- plot: an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False)
- question: a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"
- stop\_rule: a Math \[text\] that says "$upright("stop when") thin z thin upright("or") thin mu thin upright("does not change")$"
- update\_rule: a Math \[text\] that says "$mu\_j = frac(1, n\_j) sum\_(i: z\_i=j) x\_i$"

#### Beats

##### [01:35.014](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=95.01412499999999)

Narration: Here is our concrete problem. We have twelve observations, two features, and a requested value k equals two. The algorithm must return two clusters.

Board: Empty.

Actions:
- [01:35.014](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=95.01412499999999): question is shown on the screen, written out.
- [01:45.382](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=105.38162499999999): question moves to a new place on the board.

##### [01:45.982](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=105.981625)

Narration: First put the data on the plane. At this stage the points have no fitted cluster identity.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"

Actions:
- [01:45.982](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=105.981625): plot is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_2 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_3 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_4 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_5 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_6 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_7 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_8 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_9 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_10 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_11 is shown on the screen, written out.
- [01:49.511](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=109.51112499999999): neutral\_points\_12 is shown on the screen, written out.

##### [01:52.514](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=112.51412499999999)

Narration: K-means needs starting centres. These two are deliberately away from the middle of the groups. They are guesses, not observations and not yet fitted means.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); neutral\_points — a Point \[gray\] drawn in plot (location=(-3.2, 1.0)); neutral\_points\_2 — a Point \[gray\] drawn in plot (location=(-2.8, 1.5)); neutral\_points\_3 — a Point \[gray\] drawn in plot (location=(-2.5, 0.8)); neutral\_points\_4 — a Point \[gray\] drawn in plot (location=(-3.4, 0.2)); neutral\_points\_5 — a Point \[gray\] drawn in plot (location=(-2.7, 0.0)); neutral\_points\_6 — a Point \[gray\] drawn in plot (location=(-2.0, 1.1)); neutral\_points\_7 — a Point \[gray\] drawn in plot (location=(1.5, -1.0)); neutral\_points\_8 — a Point \[gray\] drawn in plot (location=(2.1, -1.4)); neutral\_points\_9 — a Point \[gray\] drawn in plot (location=(2.8, -0.7)); neutral\_points\_10 — a Point \[gray\] drawn in plot (location=(1.9, -0.2)); neutral\_points\_11 — a Point \[gray\] drawn in plot (location=(3.2, -1.5)); neutral\_points\_12 — a Point \[gray\] drawn in plot (location=(2.7, 0.1))

Actions:
- [01:54.662](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=114.66212499999999): centre\_1 is shown on the screen, written out.
- [01:54.662](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=114.66212499999999): centre\_2 is shown on the screen, written out.

##### [02:4.283](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=124.28312499999998)

Narration: The assignment step examines every observation. For each centre, compute squared Euclidean distance across the features, then give the observation to the centre with the smaller total.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); neutral\_points — a Point \[gray\] drawn in plot (location=(-3.2, 1.0)); neutral\_points\_2 — a Point \[gray\] drawn in plot (location=(-2.8, 1.5)); neutral\_points\_3 — a Point \[gray\] drawn in plot (location=(-2.5, 0.8)); neutral\_points\_4 — a Point \[gray\] drawn in plot (location=(-3.4, 0.2)); neutral\_points\_5 — a Point \[gray\] drawn in plot (location=(-2.7, 0.0)); neutral\_points\_6 — a Point \[gray\] drawn in plot (location=(-2.0, 1.1)); neutral\_points\_7 — a Point \[gray\] drawn in plot (location=(1.5, -1.0)); neutral\_points\_8 — a Point \[gray\] drawn in plot (location=(2.1, -1.4)); neutral\_points\_9 — a Point \[gray\] drawn in plot (location=(2.8, -0.7)); neutral\_points\_10 — a Point \[gray\] drawn in plot (location=(1.9, -0.2)); neutral\_points\_11 — a Point \[gray\] drawn in plot (location=(3.2, -1.5)); neutral\_points\_12 — a Point \[gray\] drawn in plot (location=(2.7, 0.1)); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11)

Actions:
- [02:4.945](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=124.94512499999999): plot moves to a new place on the board.
- [02:4.945](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=124.94512499999999): assign\_rule is shown on the screen, written out.
- [02:9.6](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=129.600125): assign\_rule (the "sum\_l (x\_(i l) - mu\_(j l))^2" part) is emphasized.
- [02:15.649](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=135.649125): assign\_rule (the "sum\_l (x\_(i l) - mu\_(j l))^2" part) is no longer emphasized.

##### [02:16.249](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=136.249125)

Narration: After that comparison, these six points belong to the red centre and these six belong to the green centre. The colour is the hard cluster label z.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); assign\_rule — a Math \[text\] that says "$z\_i = op("arg min")\_j sum\_l (x\_(i l) - mu\_(j l))^2$"; neutral\_points — a Point \[gray\] drawn in plot (location=(-3.2, 1.0)); neutral\_points\_2 — a Point \[gray\] drawn in plot (location=(-2.8, 1.5)); neutral\_points\_3 — a Point \[gray\] drawn in plot (location=(-2.5, 0.8)); neutral\_points\_4 — a Point \[gray\] drawn in plot (location=(-3.4, 0.2)); neutral\_points\_5 — a Point \[gray\] drawn in plot (location=(-2.7, 0.0)); neutral\_points\_6 — a Point \[gray\] drawn in plot (location=(-2.0, 1.1)); neutral\_points\_7 — a Point \[gray\] drawn in plot (location=(1.5, -1.0)); neutral\_points\_8 — a Point \[gray\] drawn in plot (location=(2.1, -1.4)); neutral\_points\_9 — a Point \[gray\] drawn in plot (location=(2.8, -0.7)); neutral\_points\_10 — a Point \[gray\] drawn in plot (location=(1.9, -0.2)); neutral\_points\_11 — a Point \[gray\] drawn in plot (location=(3.2, -1.5)); neutral\_points\_12 — a Point \[gray\] drawn in plot (location=(2.7, 0.1)); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11)

Actions:
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_2 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_3 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_4 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_5 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_6 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_7 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_8 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_9 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_10 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_11 is hidden from the screen.
- [02:17.12](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=137.120125): neutral\_points\_12 is hidden from the screen.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a is shown on the screen, written out.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a\_2 is shown on the screen, written out.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a\_3 is shown on the screen, written out.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a\_4 is shown on the screen, written out.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a\_5 is shown on the screen, written out.
- [02:19.5](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=139.500125): assigned\_a\_6 is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b\_2 is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b\_3 is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b\_4 is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b\_5 is shown on the screen, written out.
- [02:21.613](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=141.613125): assigned\_b\_6 is shown on the screen, written out.
- [02:24.782](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=144.782125): assign\_rule (the "z\_i" part) is emphasized.
- [02:25.851](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=145.85062499999998): assign\_rule (the "z\_i" part) is no longer emphasized.

##### [02:26.451](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=146.450625)

Narration: Now freeze the assignments and update one centre at a time. The new red centre is the coordinate-wise mean of the six red observations.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); assign\_rule — a Math \[text\] that says "$z\_i = op("arg min")\_j sum\_l (x\_(i l) - mu\_(j l))^2$"; centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1))

Actions:
- [02:28.25](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=148.250125): update\_rule is shown on the screen, written out.
- [02:30.92](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=150.92012499999998): move\_1 is shown on the screen, written out.
- [02:32.592](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=152.59212499999998): mean\_1 is shown on the screen, written out.

##### [02:35.631](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=155.63062499999998)

Narration: The green centre is calculated in exactly the same way from the green observations. A centre is therefore a fitted average, not necessarily a row that actually occurs in the data.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); assign\_rule — a Math \[text\] that says "$z\_i = op("arg min")\_j sum\_l (x\_(i l) - mu\_(j l))^2$"; update\_rule — a Math \[text\] that says "$mu\_j = frac(1, n\_j) sum\_(i: z\_i=j) x\_i$"; centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); mean\_1 — a Point \[yellow\] labelled "overline(x)\_1" drawn in plot (location=(-2.7666666667, 0.7666666667)); move\_1 — a Vector \[yellow\] drawn in plot (start=(-3.5, -1.5), end=(-2.7666666667, 0.7666666667))

Actions:
- [02:36.153](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=156.153125): move\_2 is shown on the screen, written out.
- [02:38.498](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=158.498125): mean\_2 is shown on the screen, written out.
- [02:42.608](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=162.60812499999997): update\_rule (the "frac(1, n\_j)" part) is emphasized.
- [02:46.521](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=166.520625): update\_rule (the "frac(1, n\_j)" part) is no longer emphasized.

##### [02:47.121](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=167.120625)

Narration: Move both centres to those means. As the centres travel, the assigned observations stay fixed. When the centres arrive, one full k-means pass is complete.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); assign\_rule — a Math \[text\] that says "$z\_i = op("arg min")\_j sum\_l (x\_(i l) - mu\_(j l))^2$"; update\_rule — a Math \[text\] that says "$mu\_j = frac(1, n\_j) sum\_(i: z\_i=j) x\_i$"; centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); mean\_1 — a Point \[yellow\] labelled "overline(x)\_1" drawn in plot (location=(-2.7666666667, 0.7666666667)); move\_1 — a Vector \[yellow\] drawn in plot (start=(-3.5, -1.5), end=(-2.7666666667, 0.7666666667)); mean\_2 — a Point \[yellow\] labelled "overline(x)\_2" drawn in plot (location=(2.3666666667, -0.7833333333)); move\_2 — a Vector \[yellow\] drawn in plot (start=(3.5, 1.5), end=(2.3666666667, -0.7833333333))

Actions:
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_1 is redrawn as the numbers it depends on change.
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_2 is redrawn as the numbers it depends on change.
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_1\_x ticks to -2.7666666667.
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_1\_y ticks to 0.7666666667.
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_2\_x ticks to 2.3666666667.
- [02:50.835](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=170.835125): centre\_2\_y ticks to -0.7833333333.
- [02:58.173](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.17262499999998): update\_rule moves to a new place on the board.
- [02:58.173](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.17262499999998): assign\_rule is hidden from the screen — left the board.

##### [02:58.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.772625)

Narration: Then repeat. With the centres in their new positions, calculate every nearest-centre assignment again.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); update\_rule — a Math \[text\] that says "$mu\_j = frac(1, n\_j) sum\_(i: z\_i=j) x\_i$"; centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); mean\_1 — a Point \[yellow\] labelled "overline(x)\_1" drawn in plot (location=(-2.7666666667, 0.7666666667)); move\_1 — a Vector \[yellow\] drawn in plot (start=(-3.5, -1.5), end=(-2.7666666667, 0.7666666667)); mean\_2 — a Point \[yellow\] labelled "overline(x)\_2" drawn in plot (location=(2.3666666667, -0.7833333333)); move\_2 — a Vector \[yellow\] drawn in plot (start=(3.5, 1.5), end=(2.3666666667, -0.7833333333))

Actions:
- [02:58.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.772625): mean\_1 is hidden from the screen.
- [02:58.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.772625): mean\_2 is hidden from the screen.
- [02:58.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.772625): move\_1 is hidden from the screen.
- [02:58.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=178.772625): move\_2 is hidden from the screen.
- [02:59.469](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=179.469125): stop\_rule is shown on the screen, written out.
- [02:59.469](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=179.469125): history is shown on the screen, written out.
- [03:1.884](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=181.88412499999998): history is shown on the screen, written out.

##### [03:6.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=186.257625)

Narration: In this example every point keeps its colour. Recomputing the two means therefore returns the same two centres. The second pass changes neither the assignments nor the centres.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); update\_rule — a Math \[text\] that says "$mu\_j = frac(1, n\_j) sum\_(i: z\_i=j) x\_i$"; centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); stop\_rule — a Math \[text\] that says "$upright("stop when") thin z thin upright("or") thin mu thin upright("does not change")$"

Actions:
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a\_2 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a\_3 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a\_4 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a\_5 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_a\_6 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b\_2 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b\_3 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b\_4 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b\_5 is indicated — a transient flash.
- [03:8.405](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=188.405125): assigned\_b\_6 is indicated — a transient flash.
- [03:14.199](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=194.19912499999998): history is shown on the screen, written out.

##### [03:18.177](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=198.177125)

Narration: That is convergence. Implementations may stop when assignments are identical, when centre movement is below a tolerance, or when a maximum iteration count is reached.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [03:21.823](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=201.823125): stop\_rule (the "z" part) is emphasized.
- [03:23.854](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=203.854125): stop\_rule (the "mu" part) is emphasized.
- [03:23.854](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=203.854125): stop\_rule (the "z" part) is no longer emphasized.
- [03:28.836](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=208.835625): stop\_rule moves to a new place on the board.
- [03:28.836](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=208.835625): history is hidden from the screen — left the board.
- [03:28.836](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=208.835625): update\_rule is hidden from the screen — left the board.
- [03:28.836](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=208.835625): stop\_rule (the "mu" part) is no longer emphasized.

##### [03:29.436](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=209.435625)

Narration: The loop is alternating optimization. With centres fixed, nearest-centre assignment cannot increase the within-cluster sum of squares. With assignments fixed, replacing each centre by its mean cannot increase it either.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); stop\_rule — a Math \[text\] that says "$upright("stop when") thin z thin upright("or") thin mu thin upright("does not change")$"

Actions:
- [03:37.075](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=217.07512499999999): objective is shown on the screen, written out.
- [03:37.075](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=217.07512499999999): objective (the "J" part) is emphasized.
- [03:43.763](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=223.762625): objective (the "J" part) is no longer emphasized.

##### [03:44.363](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=224.36262499999998)

Narration: So the objective falls or stays level on every pass. Because only finitely many hard assignments exist, the procedure eventually stops. What this does not prove is that it found the best possible clustering. It may have stopped at a merely local solution.

Board: question — a Panel that says "Starting from two centres, how does k-means turn this scatter into two clusters?"; plot — an Axes (x\_range=(-4.5, 4.5), y\_range=(-2.5, 2.5), include\_ticks=False); centre\_1 — a Point \[red\] labelled "mu\_1" drawn in plot (location=(\<VariableNumber centre\_1\_x = -2.7666666667\>, \<VariableNumber c…, marker\_radius=0.11); centre\_2 — a Point \[green\] labelled "mu\_2" drawn in plot (location=(\<VariableNumber centre\_2\_x = 2.3666666667\>, \<VariableNumber ce…, marker\_radius=0.11); assigned\_a — a Point \[red\] drawn in plot (location=(-3.2, 1.0)); assigned\_a\_2 — a Point \[red\] drawn in plot (location=(-2.8, 1.5)); assigned\_a\_3 — a Point \[red\] drawn in plot (location=(-2.5, 0.8)); assigned\_a\_4 — a Point \[red\] drawn in plot (location=(-3.4, 0.2)); assigned\_a\_5 — a Point \[red\] drawn in plot (location=(-2.7, 0.0)); assigned\_a\_6 — a Point \[red\] drawn in plot (location=(-2.0, 1.1)); assigned\_b — a Point \[green\] drawn in plot (location=(1.5, -1.0)); assigned\_b\_2 — a Point \[green\] drawn in plot (location=(2.1, -1.4)); assigned\_b\_3 — a Point \[green\] drawn in plot (location=(2.8, -0.7)); assigned\_b\_4 — a Point \[green\] drawn in plot (location=(1.9, -0.2)); assigned\_b\_5 — a Point \[green\] drawn in plot (location=(3.2, -1.5)); assigned\_b\_6 — a Point \[green\] drawn in plot (location=(2.7, 0.1)); stop\_rule — a Math \[text\] that says "$upright("stop when") thin z thin upright("or") thin mu thin upright("does not change")$"; objective — a Math \[text\] that says "$J = sum\_i sum\_l (x\_(i l) - mu\_(z\_i l))^2$"

Actions:
- [03:45.721](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=225.72112499999997): A box is drawn around objective.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): objective is hidden from the screen — left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): plot is hidden from the screen — left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): centre\_1 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): centre\_2 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a\_2 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a\_3 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a\_4 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a\_5 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_a\_6 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b\_2 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b\_3 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b\_4 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b\_5 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): assigned\_b\_6 is hidden from the screen — plot left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): question is hidden from the screen — left the board.
- [04:1.07](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=241.06983333333335): stop\_rule is hidden from the screen — left the board.

### Scene 3: [Initialization Changes the Answer](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=242.11149999999998)

Span: 04:2.111–05:49.139 (242.11149999999998s–349.1395s).

#### Objects

- bad: a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2))
- bad\_centres: a Point \[red\] labelled "mu\_1" drawn in bad (location=(-3.13, -0.43))
- bad\_centres\_2: a Point \[green\] labelled "mu\_2" drawn in bad (location=(-2.77, 0.8))
- bad\_centres\_3: a Point \[blue\] labelled "mu\_3" drawn in bad (location=(1.98, 0.07))
- bad\_left\_high: a Point \[green\] drawn in bad (location=(-3.0, 0.8))
- bad\_left\_high\_2: a Point \[green\] drawn in bad (location=(-2.4, 0.4))
- bad\_left\_high\_3: a Point \[green\] drawn in bad (location=(-2.9, 1.2))
- bad\_left\_low: a Point \[red\] drawn in bad (location=(-3.5, -0.8))
- bad\_left\_low\_2: a Point \[red\] drawn in bad (location=(-3.3, 0.0))
- bad\_left\_low\_3: a Point \[red\] drawn in bad (location=(-2.6, -0.5))
- bad\_neutral: a Point \[gray\] drawn in bad (location=(-3.5, -0.8))
- bad\_neutral\_10: a Point \[gray\] drawn in bad (location=(2.3, 2.0))
- bad\_neutral\_11: a Point \[gray\] drawn in bad (location=(2.6, 1.2))
- bad\_neutral\_12: a Point \[gray\] drawn in bad (location=(1.2, -1.0))
- bad\_neutral\_13: a Point \[gray\] drawn in bad (location=(1.6, -1.7))
- bad\_neutral\_14: a Point \[gray\] drawn in bad (location=(2.1, -1.3))
- bad\_neutral\_15: a Point \[gray\] drawn in bad (location=(2.5, -1.9))
- bad\_neutral\_16: a Point \[gray\] drawn in bad (location=(2.8, -0.8))
- bad\_neutral\_2: a Point \[gray\] drawn in bad (location=(-3.3, 0.0))
- bad\_neutral\_3: a Point \[gray\] drawn in bad (location=(-3.0, 0.8))
- bad\_neutral\_4: a Point \[gray\] drawn in bad (location=(-2.6, -0.5))
- bad\_neutral\_5: a Point \[gray\] drawn in bad (location=(-2.4, 0.4))
- bad\_neutral\_6: a Point \[gray\] drawn in bad (location=(-2.9, 1.2))
- bad\_neutral\_7: a Point \[gray\] drawn in bad (location=(1.2, 1.1))
- bad\_neutral\_8: a Point \[gray\] drawn in bad (location=(1.5, 1.7))
- bad\_neutral\_9: a Point \[gray\] drawn in bad (location=(2.0, 1.4))
- bad\_right\_merged: a Point \[blue\] drawn in bad (location=(1.2, 1.1))
- bad\_right\_merged\_10: a Point \[blue\] drawn in bad (location=(2.8, -0.8))
- bad\_right\_merged\_2: a Point \[blue\] drawn in bad (location=(1.5, 1.7))
- bad\_right\_merged\_3: a Point \[blue\] drawn in bad (location=(2.0, 1.4))
- bad\_right\_merged\_4: a Point \[blue\] drawn in bad (location=(2.3, 2.0))
- bad\_right\_merged\_5: a Point \[blue\] drawn in bad (location=(2.6, 1.2))
- bad\_right\_merged\_6: a Point \[blue\] drawn in bad (location=(1.2, -1.0))
- bad\_right\_merged\_7: a Point \[blue\] drawn in bad (location=(1.6, -1.7))
- bad\_right\_merged\_8: a Point \[blue\] drawn in bad (location=(2.1, -1.3))
- bad\_right\_merged\_9: a Point \[blue\] drawn in bad (location=(2.5, -1.9))
- bad\_seeds: a Point \[yellow\] labelled "1" drawn in bad (location=(-3.6, -0.9))
- bad\_seeds\_2: a Point \[yellow\] labelled "2" drawn in bad (location=(-3.1, 0.1))
- bad\_seeds\_3: a Point \[yellow\] labelled "3" drawn in bad (location=(-2.5, 0.9))
- good: a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2))
- good\_bottom: a Point \[blue\] drawn in good (location=(1.2, -1.0))
- good\_bottom\_2: a Point \[blue\] drawn in good (location=(1.6, -1.7))
- good\_bottom\_3: a Point \[blue\] drawn in good (location=(2.1, -1.3))
- good\_bottom\_4: a Point \[blue\] drawn in good (location=(2.5, -1.9))
- good\_bottom\_5: a Point \[blue\] drawn in good (location=(2.8, -0.8))
- good\_centres: a Point \[red\] labelled "mu\_1" drawn in good (location=(-2.95, 0.18))
- good\_centres\_2: a Point \[green\] labelled "mu\_2" drawn in good (location=(1.92, 1.48))
- good\_centres\_3: a Point \[blue\] labelled "mu\_3" drawn in good (location=(2.04, -1.34))
- good\_left: a Point \[red\] drawn in good (location=(-3.5, -0.8))
- good\_left\_2: a Point \[red\] drawn in good (location=(-3.3, 0.0))
- good\_left\_3: a Point \[red\] drawn in good (location=(-3.0, 0.8))
- good\_left\_4: a Point \[red\] drawn in good (location=(-2.6, -0.5))
- good\_left\_5: a Point \[red\] drawn in good (location=(-2.4, 0.4))
- good\_left\_6: a Point \[red\] drawn in good (location=(-2.9, 1.2))
- good\_neutral: a Point \[gray\] drawn in good (location=(-3.5, -0.8))
- good\_neutral\_10: a Point \[gray\] drawn in good (location=(2.3, 2.0))
- good\_neutral\_11: a Point \[gray\] drawn in good (location=(2.6, 1.2))
- good\_neutral\_12: a Point \[gray\] drawn in good (location=(1.2, -1.0))
- good\_neutral\_13: a Point \[gray\] drawn in good (location=(1.6, -1.7))
- good\_neutral\_14: a Point \[gray\] drawn in good (location=(2.1, -1.3))
- good\_neutral\_15: a Point \[gray\] drawn in good (location=(2.5, -1.9))
- good\_neutral\_16: a Point \[gray\] drawn in good (location=(2.8, -0.8))
- good\_neutral\_2: a Point \[gray\] drawn in good (location=(-3.3, 0.0))
- good\_neutral\_3: a Point \[gray\] drawn in good (location=(-3.0, 0.8))
- good\_neutral\_4: a Point \[gray\] drawn in good (location=(-2.6, -0.5))
- good\_neutral\_5: a Point \[gray\] drawn in good (location=(-2.4, 0.4))
- good\_neutral\_6: a Point \[gray\] drawn in good (location=(-2.9, 1.2))
- good\_neutral\_7: a Point \[gray\] drawn in good (location=(1.2, 1.1))
- good\_neutral\_8: a Point \[gray\] drawn in good (location=(1.5, 1.7))
- good\_neutral\_9: a Point \[gray\] drawn in good (location=(2.0, 1.4))
- good\_seeds: a Point \[yellow\] labelled "1" drawn in good (location=(-3.4, 0.1))
- good\_seeds\_2: a Point \[yellow\] labelled "2" drawn in good (location=(1.7, 1.8))
- good\_seeds\_3: a Point \[yellow\] labelled "3" drawn in good (location=(1.8, -1.5))
- good\_top: a Point \[green\] drawn in good (location=(1.2, 1.1))
- good\_top\_2: a Point \[green\] drawn in good (location=(1.5, 1.7))
- good\_top\_3: a Point \[green\] drawn in good (location=(2.0, 1.4))
- good\_top\_4: a Point \[green\] drawn in good (location=(2.3, 2.0))
- good\_top\_5: a Point \[green\] drawn in good (location=(2.6, 1.2))
- heading: a Heading that says "Same Data, Different Starts"
- left\_label: a Tex \[text\] that says "Centres spread across the data"
- local\_note: a Text \[text\] that says "Both outcomes are stable under another assignment and mean-update pass."
- objective: a Math \[text\] that says "$J = sum\_i sum\_l (x\_(i l) - mu\_(z\_i l))^2$"
- remedy\_1: a Text \[text\] that says "Use k-means++ or another dispersed seeding rule."
- remedy\_2: a Text \[text\] that says "Run many independent starts, not one."
- remedy\_3: a Text \[text\] that says "Keep the lowest objective, then inspect the clustering."
- remedy\_4: a Text \[text\] that says "Report instability when several credible answers compete."
- remedy\_heading: a Heading that says "Treat Initialization as Part of the Fit"
- right\_label: a Tex \[text\] that says "Centres crowded on the left"

#### Beats

##### [04:2.111](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=242.11149999999998)

Narration: K-means can finish at different answers on the same data because its objective is not generally convex in all assignments and centres together. Here are two runs with k equal to three.

Board: Empty.

Actions:
- [04:2.111](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=242.11149999999998): heading is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_2 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_3 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_4 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_5 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_6 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_7 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_8 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_9 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_10 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_11 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_12 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_13 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_14 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_15 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): good\_neutral\_16 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_2 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_3 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_4 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_5 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_6 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_7 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_8 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_9 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_10 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_11 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_12 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_13 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_14 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_15 is shown on the screen, written out.
- [04:4.781](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=244.78149999999997): bad\_neutral\_16 is shown on the screen, written out.
- [04:11.596](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=251.5965): good is shown on the screen, written out.
- [04:11.596](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=251.5965): bad is shown on the screen, written out.

##### [04:14.797](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=254.79749999999999)

Narration: On the left, the starting centres are spread across the visible groups. On the right, an unlucky draw crowds all three starting centres into the left-hand group.

Board: good — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); bad — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); heading — a Heading that says "Same Data, Different Starts"; good\_neutral — a Point \[gray\] drawn in good (location=(-3.5, -0.8)); good\_neutral\_2 — a Point \[gray\] drawn in good (location=(-3.3, 0.0)); good\_neutral\_3 — a Point \[gray\] drawn in good (location=(-3.0, 0.8)); good\_neutral\_4 — a Point \[gray\] drawn in good (location=(-2.6, -0.5)); good\_neutral\_5 — a Point \[gray\] drawn in good (location=(-2.4, 0.4)); good\_neutral\_6 — a Point \[gray\] drawn in good (location=(-2.9, 1.2)); good\_neutral\_7 — a Point \[gray\] drawn in good (location=(1.2, 1.1)); good\_neutral\_8 — a Point \[gray\] drawn in good (location=(1.5, 1.7)); good\_neutral\_9 — a Point \[gray\] drawn in good (location=(2.0, 1.4)); good\_neutral\_10 — a Point \[gray\] drawn in good (location=(2.3, 2.0)); good\_neutral\_11 — a Point \[gray\] drawn in good (location=(2.6, 1.2)); good\_neutral\_12 — a Point \[gray\] drawn in good (location=(1.2, -1.0)); good\_neutral\_13 — a Point \[gray\] drawn in good (location=(1.6, -1.7)); good\_neutral\_14 — a Point \[gray\] drawn in good (location=(2.1, -1.3)); good\_neutral\_15 — a Point \[gray\] drawn in good (location=(2.5, -1.9)); good\_neutral\_16 — a Point \[gray\] drawn in good (location=(2.8, -0.8)); bad\_neutral — a Point \[gray\] drawn in bad (location=(-3.5, -0.8)); bad\_neutral\_2 — a Point \[gray\] drawn in bad (location=(-3.3, 0.0)); bad\_neutral\_3 — a Point \[gray\] drawn in bad (location=(-3.0, 0.8)); bad\_neutral\_4 — a Point \[gray\] drawn in bad (location=(-2.6, -0.5)); bad\_neutral\_5 — a Point \[gray\] drawn in bad (location=(-2.4, 0.4)); bad\_neutral\_6 — a Point \[gray\] drawn in bad (location=(-2.9, 1.2)); bad\_neutral\_7 — a Point \[gray\] drawn in bad (location=(1.2, 1.1)); bad\_neutral\_8 — a Point \[gray\] drawn in bad (location=(1.5, 1.7)); bad\_neutral\_9 — a Point \[gray\] drawn in bad (location=(2.0, 1.4)); bad\_neutral\_10 — a Point \[gray\] drawn in bad (location=(2.3, 2.0)); bad\_neutral\_11 — a Point \[gray\] drawn in bad (location=(2.6, 1.2)); bad\_neutral\_12 — a Point \[gray\] drawn in bad (location=(1.2, -1.0)); bad\_neutral\_13 — a Point \[gray\] drawn in bad (location=(1.6, -1.7)); bad\_neutral\_14 — a Point \[gray\] drawn in bad (location=(2.1, -1.3)); bad\_neutral\_15 — a Point \[gray\] drawn in bad (location=(2.5, -1.9)); bad\_neutral\_16 — a Point \[gray\] drawn in bad (location=(2.8, -0.8))

Actions:
- [04:15.494](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=255.4945): left\_label is shown on the screen, written out.
- [04:17.212](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=257.2125): good\_seeds is shown on the screen, written out.
- [04:17.212](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=257.2125): good\_seeds\_2 is shown on the screen, written out.
- [04:17.212](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=257.2125): good\_seeds\_3 is shown on the screen, written out.
- [04:20.161](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=260.1615): right\_label is shown on the screen, written out.
- [04:21.821](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=261.82149999999996): bad\_seeds is shown on the screen, written out.
- [04:21.821](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=261.82149999999996): bad\_seeds\_2 is shown on the screen, written out.
- [04:21.821](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=261.82149999999996): bad\_seeds\_3 is shown on the screen, written out.

##### [04:25.823](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=265.823)

Narration: Run the same assignment and update loop on both sides. The favourable start settles with one centre in each visible group.

Board: left\_label — a Tex \[text\] that says "Centres spread across the data"; good — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); right\_label — a Tex \[text\] that says "Centres crowded on the left"; bad — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); heading — a Heading that says "Same Data, Different Starts"; good\_neutral — a Point \[gray\] drawn in good (location=(-3.5, -0.8)); good\_neutral\_2 — a Point \[gray\] drawn in good (location=(-3.3, 0.0)); good\_neutral\_3 — a Point \[gray\] drawn in good (location=(-3.0, 0.8)); good\_neutral\_4 — a Point \[gray\] drawn in good (location=(-2.6, -0.5)); good\_neutral\_5 — a Point \[gray\] drawn in good (location=(-2.4, 0.4)); good\_neutral\_6 — a Point \[gray\] drawn in good (location=(-2.9, 1.2)); good\_neutral\_7 — a Point \[gray\] drawn in good (location=(1.2, 1.1)); good\_neutral\_8 — a Point \[gray\] drawn in good (location=(1.5, 1.7)); good\_neutral\_9 — a Point \[gray\] drawn in good (location=(2.0, 1.4)); good\_neutral\_10 — a Point \[gray\] drawn in good (location=(2.3, 2.0)); good\_neutral\_11 — a Point \[gray\] drawn in good (location=(2.6, 1.2)); good\_neutral\_12 — a Point \[gray\] drawn in good (location=(1.2, -1.0)); good\_neutral\_13 — a Point \[gray\] drawn in good (location=(1.6, -1.7)); good\_neutral\_14 — a Point \[gray\] drawn in good (location=(2.1, -1.3)); good\_neutral\_15 — a Point \[gray\] drawn in good (location=(2.5, -1.9)); good\_neutral\_16 — a Point \[gray\] drawn in good (location=(2.8, -0.8)); bad\_neutral — a Point \[gray\] drawn in bad (location=(-3.5, -0.8)); bad\_neutral\_2 — a Point \[gray\] drawn in bad (location=(-3.3, 0.0)); bad\_neutral\_3 — a Point \[gray\] drawn in bad (location=(-3.0, 0.8)); bad\_neutral\_4 — a Point \[gray\] drawn in bad (location=(-2.6, -0.5)); bad\_neutral\_5 — a Point \[gray\] drawn in bad (location=(-2.4, 0.4)); bad\_neutral\_6 — a Point \[gray\] drawn in bad (location=(-2.9, 1.2)); bad\_neutral\_7 — a Point \[gray\] drawn in bad (location=(1.2, 1.1)); bad\_neutral\_8 — a Point \[gray\] drawn in bad (location=(1.5, 1.7)); bad\_neutral\_9 — a Point \[gray\] drawn in bad (location=(2.0, 1.4)); bad\_neutral\_10 — a Point \[gray\] drawn in bad (location=(2.3, 2.0)); bad\_neutral\_11 — a Point \[gray\] drawn in bad (location=(2.6, 1.2)); bad\_neutral\_12 — a Point \[gray\] drawn in bad (location=(1.2, -1.0)); bad\_neutral\_13 — a Point \[gray\] drawn in bad (location=(1.6, -1.7)); bad\_neutral\_14 — a Point \[gray\] drawn in bad (location=(2.1, -1.3)); bad\_neutral\_15 — a Point \[gray\] drawn in bad (location=(2.5, -1.9)); bad\_neutral\_16 — a Point \[gray\] drawn in bad (location=(2.8, -0.8)); good\_seeds — a Point \[yellow\] labelled "1" drawn in good (location=(-3.4, 0.1)); good\_seeds\_2 — a Point \[yellow\] labelled "2" drawn in good (location=(1.7, 1.8)); good\_seeds\_3 — a Point \[yellow\] labelled "3" drawn in good (location=(1.8, -1.5)); bad\_seeds — a Point \[yellow\] labelled "1" drawn in bad (location=(-3.6, -0.9)); bad\_seeds\_2 — a Point \[yellow\] labelled "2" drawn in bad (location=(-3.1, 0.1)); bad\_seeds\_3 — a Point \[yellow\] labelled "3" drawn in bad (location=(-2.5, 0.9))

Actions:
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_seeds is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_seeds\_2 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_seeds\_3 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_2 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_3 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_4 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_5 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_6 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_7 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_8 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_9 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_10 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_11 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_12 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_13 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_14 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_15 is hidden from the screen.
- [04:27.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=267.99449999999996): good\_neutral\_16 is hidden from the screen.
- [04:31.802](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=271.80249999999995): good\_centres is shown on the screen, written out.
- [04:31.802](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=271.80249999999995): good\_centres\_2 is shown on the screen, written out.
- [04:31.802](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=271.80249999999995): good\_centres\_3 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left\_2 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left\_3 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left\_4 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left\_5 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_left\_6 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_top is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_top\_2 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_top\_3 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_top\_4 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_top\_5 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_bottom is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_bottom\_2 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_bottom\_3 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_bottom\_4 is shown on the screen, written out.
- [04:32.591](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=272.5915): good\_bottom\_5 is shown on the screen, written out.

##### [04:34.306](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.30649999999997)

Narration: The unlucky run spends two centres splitting the left group. Its remaining centre absorbs both right-hand groups, even though they are visibly separated.

Board: left\_label — a Tex \[text\] that says "Centres spread across the data"; good — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); right\_label — a Tex \[text\] that says "Centres crowded on the left"; bad — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); heading — a Heading that says "Same Data, Different Starts"; bad\_neutral — a Point \[gray\] drawn in bad (location=(-3.5, -0.8)); bad\_neutral\_2 — a Point \[gray\] drawn in bad (location=(-3.3, 0.0)); bad\_neutral\_3 — a Point \[gray\] drawn in bad (location=(-3.0, 0.8)); bad\_neutral\_4 — a Point \[gray\] drawn in bad (location=(-2.6, -0.5)); bad\_neutral\_5 — a Point \[gray\] drawn in bad (location=(-2.4, 0.4)); bad\_neutral\_6 — a Point \[gray\] drawn in bad (location=(-2.9, 1.2)); bad\_neutral\_7 — a Point \[gray\] drawn in bad (location=(1.2, 1.1)); bad\_neutral\_8 — a Point \[gray\] drawn in bad (location=(1.5, 1.7)); bad\_neutral\_9 — a Point \[gray\] drawn in bad (location=(2.0, 1.4)); bad\_neutral\_10 — a Point \[gray\] drawn in bad (location=(2.3, 2.0)); bad\_neutral\_11 — a Point \[gray\] drawn in bad (location=(2.6, 1.2)); bad\_neutral\_12 — a Point \[gray\] drawn in bad (location=(1.2, -1.0)); bad\_neutral\_13 — a Point \[gray\] drawn in bad (location=(1.6, -1.7)); bad\_neutral\_14 — a Point \[gray\] drawn in bad (location=(2.1, -1.3)); bad\_neutral\_15 — a Point \[gray\] drawn in bad (location=(2.5, -1.9)); bad\_neutral\_16 — a Point \[gray\] drawn in bad (location=(2.8, -0.8)); bad\_seeds — a Point \[yellow\] labelled "1" drawn in bad (location=(-3.6, -0.9)); bad\_seeds\_2 — a Point \[yellow\] labelled "2" drawn in bad (location=(-3.1, 0.1)); bad\_seeds\_3 — a Point \[yellow\] labelled "3" drawn in bad (location=(-2.5, 0.9)); good\_left — a Point \[red\] drawn in good (location=(-3.5, -0.8)); good\_left\_2 — a Point \[red\] drawn in good (location=(-3.3, 0.0)); good\_left\_3 — a Point \[red\] drawn in good (location=(-3.0, 0.8)); good\_left\_4 — a Point \[red\] drawn in good (location=(-2.6, -0.5)); good\_left\_5 — a Point \[red\] drawn in good (location=(-2.4, 0.4)); good\_left\_6 — a Point \[red\] drawn in good (location=(-2.9, 1.2)); good\_top — a Point \[green\] drawn in good (location=(1.2, 1.1)); good\_top\_2 — a Point \[green\] drawn in good (location=(1.5, 1.7)); good\_top\_3 — a Point \[green\] drawn in good (location=(2.0, 1.4)); good\_top\_4 — a Point \[green\] drawn in good (location=(2.3, 2.0)); good\_top\_5 — a Point \[green\] drawn in good (location=(2.6, 1.2)); good\_bottom — a Point \[blue\] drawn in good (location=(1.2, -1.0)); good\_bottom\_2 — a Point \[blue\] drawn in good (location=(1.6, -1.7)); good\_bottom\_3 — a Point \[blue\] drawn in good (location=(2.1, -1.3)); good\_bottom\_4 — a Point \[blue\] drawn in good (location=(2.5, -1.9)); good\_bottom\_5 — a Point \[blue\] drawn in good (location=(2.8, -0.8)); good\_centres — a Point \[red\] labelled "mu\_1" drawn in good (location=(-2.95, 0.18)); good\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in good (location=(1.92, 1.48)); good\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in good (location=(2.04, -1.34))

Actions:
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_seeds is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_seeds\_2 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_seeds\_3 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_2 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_3 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_4 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_5 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_6 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_7 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_8 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_9 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_10 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_11 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_12 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_13 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_14 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_15 is hidden from the screen.
- [04:34.886](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=274.88649999999996): bad\_neutral\_16 is hidden from the screen.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_low is shown on the screen, written out.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_low\_2 is shown on the screen, written out.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_low\_3 is shown on the screen, written out.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_high is shown on the screen, written out.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_high\_2 is shown on the screen, written out.
- [04:36.779](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=276.7795): bad\_left\_high\_3 is shown on the screen, written out.
- [04:39.38](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.3795): bad\_centres is shown on the screen, written out.
- [04:39.38](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.3795): bad\_centres\_2 is shown on the screen, written out.
- [04:39.38](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.3795): bad\_centres\_3 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_2 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_3 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_4 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_5 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_6 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_7 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_8 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_9 is shown on the screen, written out.
- [04:39.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=279.9375): bad\_right\_merged\_10 is shown on the screen, written out.

##### [04:44.763](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=284.763)

Narration: Another pass changes neither answer. Both are local solutions, but the right-hand solution has a larger within-cluster sum of squares and a much less useful interpretation.

Board: left\_label — a Tex \[text\] that says "Centres spread across the data"; good — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); right\_label — a Tex \[text\] that says "Centres crowded on the left"; bad — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); heading — a Heading that says "Same Data, Different Starts"; good\_left — a Point \[red\] drawn in good (location=(-3.5, -0.8)); good\_left\_2 — a Point \[red\] drawn in good (location=(-3.3, 0.0)); good\_left\_3 — a Point \[red\] drawn in good (location=(-3.0, 0.8)); good\_left\_4 — a Point \[red\] drawn in good (location=(-2.6, -0.5)); good\_left\_5 — a Point \[red\] drawn in good (location=(-2.4, 0.4)); good\_left\_6 — a Point \[red\] drawn in good (location=(-2.9, 1.2)); good\_top — a Point \[green\] drawn in good (location=(1.2, 1.1)); good\_top\_2 — a Point \[green\] drawn in good (location=(1.5, 1.7)); good\_top\_3 — a Point \[green\] drawn in good (location=(2.0, 1.4)); good\_top\_4 — a Point \[green\] drawn in good (location=(2.3, 2.0)); good\_top\_5 — a Point \[green\] drawn in good (location=(2.6, 1.2)); good\_bottom — a Point \[blue\] drawn in good (location=(1.2, -1.0)); good\_bottom\_2 — a Point \[blue\] drawn in good (location=(1.6, -1.7)); good\_bottom\_3 — a Point \[blue\] drawn in good (location=(2.1, -1.3)); good\_bottom\_4 — a Point \[blue\] drawn in good (location=(2.5, -1.9)); good\_bottom\_5 — a Point \[blue\] drawn in good (location=(2.8, -0.8)); good\_centres — a Point \[red\] labelled "mu\_1" drawn in good (location=(-2.95, 0.18)); good\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in good (location=(1.92, 1.48)); good\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in good (location=(2.04, -1.34)); bad\_left\_low — a Point \[red\] drawn in bad (location=(-3.5, -0.8)); bad\_left\_low\_2 — a Point \[red\] drawn in bad (location=(-3.3, 0.0)); bad\_left\_low\_3 — a Point \[red\] drawn in bad (location=(-2.6, -0.5)); bad\_left\_high — a Point \[green\] drawn in bad (location=(-3.0, 0.8)); bad\_left\_high\_2 — a Point \[green\] drawn in bad (location=(-2.4, 0.4)); bad\_left\_high\_3 — a Point \[green\] drawn in bad (location=(-2.9, 1.2)); bad\_right\_merged — a Point \[blue\] drawn in bad (location=(1.2, 1.1)); bad\_right\_merged\_2 — a Point \[blue\] drawn in bad (location=(1.5, 1.7)); bad\_right\_merged\_3 — a Point \[blue\] drawn in bad (location=(2.0, 1.4)); bad\_right\_merged\_4 — a Point \[blue\] drawn in bad (location=(2.3, 2.0)); bad\_right\_merged\_5 — a Point \[blue\] drawn in bad (location=(2.6, 1.2)); bad\_right\_merged\_6 — a Point \[blue\] drawn in bad (location=(1.2, -1.0)); bad\_right\_merged\_7 — a Point \[blue\] drawn in bad (location=(1.6, -1.7)); bad\_right\_merged\_8 — a Point \[blue\] drawn in bad (location=(2.1, -1.3)); bad\_right\_merged\_9 — a Point \[blue\] drawn in bad (location=(2.5, -1.9)); bad\_right\_merged\_10 — a Point \[blue\] drawn in bad (location=(2.8, -0.8)); bad\_centres — a Point \[red\] labelled "mu\_1" drawn in bad (location=(-3.13, -0.43)); bad\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in bad (location=(-2.77, 0.8)); bad\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in bad (location=(1.98, 0.07))

Actions:
- [04:48.269](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=288.2695): local\_note is shown on the screen, written out.
- [04:49.755](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=289.7555): bad\_right\_merged is indicated — a transient flash.
- [04:51.938](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=291.9385): objective is shown on the screen, written out.

##### [04:56.16](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=296.16049999999996)

Narration: The practical remedy is not to trust one random start. K-means++ spreads seeds by favouring observations far from centres already chosen. It reduces bad starts, but does not abolish local minima.

Board: left\_label — a Tex \[text\] that says "Centres spread across the data"; good — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); right\_label — a Tex \[text\] that says "Centres crowded on the left"; bad — a Figure (x\_range=(-4.2, 3.5), y\_range=(-2.6, 2.6), aspect=(7.7, 5.2)); objective — a Math \[text\] that says "$J = sum\_i sum\_l (x\_(i l) - mu\_(z\_i l))^2$"; local\_note — a Text \[text\] that says "Both outcomes are stable under another assignment and mean-update pass."; heading — a Heading that says "Same Data, Different Starts"; good\_left — a Point \[red\] drawn in good (location=(-3.5, -0.8)); good\_left\_2 — a Point \[red\] drawn in good (location=(-3.3, 0.0)); good\_left\_3 — a Point \[red\] drawn in good (location=(-3.0, 0.8)); good\_left\_4 — a Point \[red\] drawn in good (location=(-2.6, -0.5)); good\_left\_5 — a Point \[red\] drawn in good (location=(-2.4, 0.4)); good\_left\_6 — a Point \[red\] drawn in good (location=(-2.9, 1.2)); good\_top — a Point \[green\] drawn in good (location=(1.2, 1.1)); good\_top\_2 — a Point \[green\] drawn in good (location=(1.5, 1.7)); good\_top\_3 — a Point \[green\] drawn in good (location=(2.0, 1.4)); good\_top\_4 — a Point \[green\] drawn in good (location=(2.3, 2.0)); good\_top\_5 — a Point \[green\] drawn in good (location=(2.6, 1.2)); good\_bottom — a Point \[blue\] drawn in good (location=(1.2, -1.0)); good\_bottom\_2 — a Point \[blue\] drawn in good (location=(1.6, -1.7)); good\_bottom\_3 — a Point \[blue\] drawn in good (location=(2.1, -1.3)); good\_bottom\_4 — a Point \[blue\] drawn in good (location=(2.5, -1.9)); good\_bottom\_5 — a Point \[blue\] drawn in good (location=(2.8, -0.8)); good\_centres — a Point \[red\] labelled "mu\_1" drawn in good (location=(-2.95, 0.18)); good\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in good (location=(1.92, 1.48)); good\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in good (location=(2.04, -1.34)); bad\_left\_low — a Point \[red\] drawn in bad (location=(-3.5, -0.8)); bad\_left\_low\_2 — a Point \[red\] drawn in bad (location=(-3.3, 0.0)); bad\_left\_low\_3 — a Point \[red\] drawn in bad (location=(-2.6, -0.5)); bad\_left\_high — a Point \[green\] drawn in bad (location=(-3.0, 0.8)); bad\_left\_high\_2 — a Point \[green\] drawn in bad (location=(-2.4, 0.4)); bad\_left\_high\_3 — a Point \[green\] drawn in bad (location=(-2.9, 1.2)); bad\_right\_merged — a Point \[blue\] drawn in bad (location=(1.2, 1.1)); bad\_right\_merged\_2 — a Point \[blue\] drawn in bad (location=(1.5, 1.7)); bad\_right\_merged\_3 — a Point \[blue\] drawn in bad (location=(2.0, 1.4)); bad\_right\_merged\_4 — a Point \[blue\] drawn in bad (location=(2.3, 2.0)); bad\_right\_merged\_5 — a Point \[blue\] drawn in bad (location=(2.6, 1.2)); bad\_right\_merged\_6 — a Point \[blue\] drawn in bad (location=(1.2, -1.0)); bad\_right\_merged\_7 — a Point \[blue\] drawn in bad (location=(1.6, -1.7)); bad\_right\_merged\_8 — a Point \[blue\] drawn in bad (location=(2.1, -1.3)); bad\_right\_merged\_9 — a Point \[blue\] drawn in bad (location=(2.5, -1.9)); bad\_right\_merged\_10 — a Point \[blue\] drawn in bad (location=(2.8, -0.8)); bad\_centres — a Point \[red\] labelled "mu\_1" drawn in bad (location=(-3.13, -0.43)); bad\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in bad (location=(-2.77, 0.8)); bad\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in bad (location=(1.98, 0.07))

Actions:
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_low is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_low\_2 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_low\_3 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_high is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_high\_2 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_left\_high\_3 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_2 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_3 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_4 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_5 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_6 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_7 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_8 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_9 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_right\_merged\_10 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_centres is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_centres\_2 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): bad\_centres\_3 is hidden from the screen — bad left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left\_2 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left\_3 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left\_4 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left\_5 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_left\_6 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_top is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_top\_2 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_top\_3 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_top\_4 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_top\_5 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_bottom is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_bottom\_2 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_bottom\_3 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_bottom\_4 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_bottom\_5 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_centres is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_centres\_2 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): good\_centres\_3 is hidden from the screen — good left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): heading is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): left\_label is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): local\_note is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): objective is hidden from the screen — left the board.
- [05:10.534](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=310.534): right\_label is hidden from the screen — left the board.

##### [05:11.734](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=311.734)

Narration: For routine analysis, make initialization part of the specification. Use a dispersed seeding rule, then run many independent starts.

Board: Empty.

Actions:
- [05:11.734](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=311.734): remedy\_heading is shown on the screen, written out.
- [05:17.296](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=317.2955): remedy\_1 is shown on the screen, written out.
- [05:19.338](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=319.33849999999995): remedy\_2 is shown on the screen, written out.

##### [05:21.68](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=321.67999999999995)

Narration: Retain the run with the lowest objective, but still inspect its groups. A numerical improvement can be immaterial, and several nearly tied runs can imply genuine ambiguity in the data.

Board: remedy\_1 — a Text \[text\] that says "Use k-means++ or another dispersed seeding rule."; remedy\_2 — a Text \[text\] that says "Run many independent starts, not one."; remedy\_heading — a Heading that says "Treat Initialization as Part of the Fit"

Actions:
- [05:23.178](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=323.1775): remedy\_3 is shown on the screen, written out.
- [05:32.372](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=332.37249999999995): remedy\_4 is shown on the screen, written out.

##### [05:34.633](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=334.633)

Narration: Record the number of starts, the random seed, and the spread of objective values. Reproducibility here is not clerical detail. It is evidence about how strongly the data supports the fitted partition.

Board: remedy\_1 — a Text \[text\] that says "Use k-means++ or another dispersed seeding rule."; remedy\_2 — a Text \[text\] that says "Run many independent starts, not one."; remedy\_3 — a Text \[text\] that says "Keep the lowest objective, then inspect the clustering."; remedy\_4 — a Text \[text\] that says "Report instability when several credible answers compete."; remedy\_heading — a Heading that says "Treat Initialization as Part of the Fit"

Actions:
- [05:35.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=335.9565): remedy\_2 is indicated — a transient flash.
- [05:44.222](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=344.22249999999997): remedy\_4 is indicated — a transient flash.
- [05:48.098](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=348.0978333333333): remedy\_1 is hidden from the screen — left the board.
- [05:48.098](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=348.0978333333333): remedy\_2 is hidden from the screen — left the board.
- [05:48.098](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=348.0978333333333): remedy\_3 is hidden from the screen — left the board.
- [05:48.098](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=348.0978333333333): remedy\_4 is hidden from the screen — left the board.
- [05:48.098](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=348.0978333333333): remedy\_heading is hidden from the screen — left the board.

### Scene 4: [Geometry and Forced Clusters](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=349.1395)

Span: 05:49.139–08:7.93 (349.1395s–487.92993749999994s).

#### Objects

- caption\_forced: a Tex \[text\] that says "One cloud, but k equals three"
- caption\_long: a Tex \[text\] that says "Elongated groups"
- caption\_size: a Tex \[text\] that says "Very different sizes"
- diagnostic\_1: a Text \[text\] that says "Are groups roughly compact in the chosen feature scale?"
- diagnostic\_2: a Text \[text\] that says "Are their spreads and populations comparable?"
- diagnostic\_3: a Text \[text\] that says "Do assignments remain stable across starts and samples?"
- diagnostic\_4: a Text \[text\] that says "Does the requested k have a domain meaning?"
- diagnostic\_heading: a Heading that says "Questions to Ask Before Believing the Colours"
- forced\_blue: a Point \[blue\] drawn in forced\_case (location=(1.0, -0.2))
- forced\_blue\_2: a Point \[blue\] drawn in forced\_case (location=(1.4, 1.0))
- forced\_blue\_3: a Point \[blue\] drawn in forced\_case (location=(1.8, -1.0))
- forced\_blue\_4: a Point \[blue\] drawn in forced\_case (location=(2.1, 0.3))
- forced\_case: a Figure (x\_range=(-3.2, 3.2), y\_range=(-3.2, 3.2), aspect=(1.0, 1.0))
- forced\_centres: a Point \[red\] labelled "mu\_1" drawn in forced\_case (location=(-1.5, 0.0))
- forced\_centres\_2: a Point \[green\] labelled "mu\_2" drawn in forced\_case (location=(0.1, 0.2))
- forced\_centres\_3: a Point \[blue\] labelled "mu\_3" drawn in forced\_case (location=(1.5, 0.0))
- forced\_green: a Point \[green\] drawn in forced\_case (location=(-0.2, -0.9))
- forced\_green\_2: a Point \[green\] drawn in forced\_case (location=(0.0, 0.5))
- forced\_green\_3: a Point \[green\] drawn in forced\_case (location=(0.4, 1.8))
- forced\_green\_4: a Point \[green\] drawn in forced\_case (location=(0.7, -1.7))
- forced\_outline: a Circle \[gray\] drawn in forced\_case (radius=2.5)
- forced\_red: a Point \[red\] drawn in forced\_case (location=(-2.1, -0.6))
- forced\_red\_2: a Point \[red\] drawn in forced\_case (location=(-1.8, 0.8))
- forced\_red\_3: a Point \[red\] drawn in forced\_case (location=(-1.3, -1.4))
- forced\_red\_4: a Point \[red\] drawn in forced\_case (location=(-1.0, 0.1))
- forced\_red\_5: a Point \[red\] drawn in forced\_case (location=(-0.7, 1.6))
- heading: a Heading that says "Three Ways the Geometry Can Mislead"
- large\_kept: a Point \[blue\] drawn in size\_case (location=(-2.8, -0.2))
- large\_kept\_2: a Point \[blue\] drawn in size\_case (location=(-2.2, 1.0))
- large\_kept\_3: a Point \[blue\] drawn in size\_case (location=(-2.0, -1.2))
- large\_kept\_4: a Point \[blue\] drawn in size\_case (location=(-1.5, 0.3))
- large\_kept\_5: a Point \[blue\] drawn in size\_case (location=(-1.0, 1.5))
- large\_kept\_6: a Point \[blue\] drawn in size\_case (location=(-0.8, -1.4))
- large\_kept\_7: a Point \[blue\] drawn in size\_case (location=(-0.3, 0.7))
- large\_kept\_8: a Point \[blue\] drawn in size\_case (location=(0.1, -0.5))
- large\_outline: a Circle \[gray\] drawn in size\_case (center=(-1.0, 0.0), radius=2.0)
- large\_stolen: a Point \[red\] drawn in size\_case (location=(0.6, 0.4))
- large\_stolen\_2: a Point \[red\] drawn in size\_case (location=(0.9, -0.9))
- long\_case: a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0))
- long\_centre\_1: a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0))
- long\_centre\_2: a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2))
- long\_cut: a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True)
- long\_left: a Point \[red\] drawn in long\_case (location=(-3.0, -1.9))
- long\_left\_2: a Point \[red\] drawn in long\_case (location=(-2.1, -1.4))
- long\_left\_3: a Point \[red\] drawn in long\_case (location=(-1.2, -0.9))
- long\_left\_4: a Point \[red\] drawn in long\_case (location=(-0.2, -0.3))
- long\_left\_5: a Point \[red\] drawn in long\_case (location=(-3.0, -0.5))
- long\_left\_6: a Point \[red\] drawn in long\_case (location=(-2.1, 0.0))
- long\_left\_7: a Point \[red\] drawn in long\_case (location=(-1.2, 0.5))
- long\_left\_8: a Point \[red\] drawn in long\_case (location=(-0.2, 1.1))
- long\_outline\_1: a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False)
- long\_outline\_2: a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False)
- long\_right: a Point \[green\] drawn in long\_case (location=(0.8, 0.2))
- long\_right\_2: a Point \[green\] drawn in long\_case (location=(1.8, 0.8))
- long\_right\_3: a Point \[green\] drawn in long\_case (location=(2.8, 1.3))
- long\_right\_4: a Point \[green\] drawn in long\_case (location=(0.8, 1.6))
- long\_right\_5: a Point \[green\] drawn in long\_case (location=(1.8, 2.2))
- long\_right\_6: a Point \[green\] drawn in long\_case (location=(2.8, 2.7))
- size\_boundary: a Line \[yellow\] drawn in size\_case (start=(0.35, -2.4), end=(0.35, 2.4), dashed=True)
- size\_case: a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0))
- size\_centre\_1: a Point \[blue\] labelled "mu\_1" drawn in size\_case (location=(-1.2, 0.1))
- size\_centre\_2: a Point \[red\] labelled "mu\_2" drawn in size\_case (location=(1.7, -0.2))
- small\_assigned: a Point \[red\] drawn in size\_case (location=(1.7, -0.2))
- small\_assigned\_2: a Point \[red\] drawn in size\_case (location=(1.9, 0.3))
- small\_assigned\_3: a Point \[red\] drawn in size\_case (location=(2.1, -0.4))
- small\_assigned\_4: a Point \[red\] drawn in size\_case (location=(2.3, 0.2))
- small\_assigned\_5: a Point \[red\] drawn in size\_case (location=(2.5, -0.1))
- small\_outline: a Circle \[gray\] drawn in size\_case (center=(2.1, 0.0), radius=0.7)

#### Beats

##### [05:49.139](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=349.1395)

Narration: The nearest-centre rule creates Voronoi cells: regions separated by straight boundaries. That simple geometry explains several important failures.

Board: Empty.

Actions:
- [05:49.139](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=349.1395): heading is shown on the screen, written out.

##### [05:59.968](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=359.968)

Narration: First, consider two long natural groups. Their gray outlines run diagonally across the feature space.

Board: heading — a Heading that says "Three Ways the Geometry Can Mislead"

Actions:
- [06:0.317](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=360.3165): long\_case is shown on the screen, written out.
- [06:1.803](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=361.8025): caption\_long is shown on the screen, written out.
- [06:4.24](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=364.2405): long\_outline\_1 is shown on the screen, written out.
- [06:4.24](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=364.2405): long\_outline\_2 is shown on the screen, written out.

##### [06:8.195](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=368.195)

Narration: With these fitted centres, nearest-centre assignment makes a nearly vertical cut. Red and green divide both long groups across their length rather than following the two elongated densities.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False)

Actions:
- [06:9.461](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=369.4605): long\_centre\_1 is shown on the screen, written out.
- [06:9.461](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=369.4605): long\_centre\_2 is shown on the screen, written out.
- [06:12.271](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=372.2705): long\_cut is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_2 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_3 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_4 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_5 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_6 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_7 is shown on the screen, written out.
- [06:13.791](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=373.7915): long\_left\_8 is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right\_2 is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right\_3 is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right\_4 is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right\_5 is shown on the screen, written out.
- [06:14.175](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=374.1745): long\_right\_6 is shown on the screen, written out.

##### [06:20.614](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=380.614)

Narration: K-means has a centre for location, but no parameter for orientation or different spread in different directions. Squared Euclidean distance therefore prefers compact, roughly spherical clusters.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False); long\_left — a Point \[red\] drawn in long\_case (location=(-3.0, -1.9)); long\_left\_2 — a Point \[red\] drawn in long\_case (location=(-2.1, -1.4)); long\_left\_3 — a Point \[red\] drawn in long\_case (location=(-1.2, -0.9)); long\_left\_4 — a Point \[red\] drawn in long\_case (location=(-0.2, -0.3)); long\_left\_5 — a Point \[red\] drawn in long\_case (location=(-3.0, -0.5)); long\_left\_6 — a Point \[red\] drawn in long\_case (location=(-2.1, 0.0)); long\_left\_7 — a Point \[red\] drawn in long\_case (location=(-1.2, 0.5)); long\_left\_8 — a Point \[red\] drawn in long\_case (location=(-0.2, 1.1)); long\_right — a Point \[green\] drawn in long\_case (location=(0.8, 0.2)); long\_right\_2 — a Point \[green\] drawn in long\_case (location=(1.8, 0.8)); long\_right\_3 — a Point \[green\] drawn in long\_case (location=(2.8, 1.3)); long\_right\_4 — a Point \[green\] drawn in long\_case (location=(0.8, 1.6)); long\_right\_5 — a Point \[green\] drawn in long\_case (location=(1.8, 2.2)); long\_right\_6 — a Point \[green\] drawn in long\_case (location=(2.8, 2.7)); long\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0)); long\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2)); long\_cut — a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True)

Actions:
- [06:29.24](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=389.2405): long\_cut is indicated — a transient flash.

##### [06:34.207](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=394.2065)

Narration: Second, place one small dense cluster beside one large diffuse cluster. The gray circles show the intended populations.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [06:34.509](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=394.5085): size\_case is shown on the screen, written out.
- [06:35.889](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=395.8895): caption\_size is shown on the screen, written out.
- [06:40.44](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=400.4405): large\_outline is shown on the screen, written out.
- [06:40.44](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=400.4405): small\_outline is shown on the screen, written out.

##### [06:43.479](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.479)

Narration: The large group contributes many more squared distances to the objective. A centre can reduce that cost by moving toward it, while the boundary gives part of the large group to the small cluster.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; size\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); caption\_size — a Tex \[text\] that says "Very different sizes"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False); long\_left — a Point \[red\] drawn in long\_case (location=(-3.0, -1.9)); long\_left\_2 — a Point \[red\] drawn in long\_case (location=(-2.1, -1.4)); long\_left\_3 — a Point \[red\] drawn in long\_case (location=(-1.2, -0.9)); long\_left\_4 — a Point \[red\] drawn in long\_case (location=(-0.2, -0.3)); long\_left\_5 — a Point \[red\] drawn in long\_case (location=(-3.0, -0.5)); long\_left\_6 — a Point \[red\] drawn in long\_case (location=(-2.1, 0.0)); long\_left\_7 — a Point \[red\] drawn in long\_case (location=(-1.2, 0.5)); long\_left\_8 — a Point \[red\] drawn in long\_case (location=(-0.2, 1.1)); long\_right — a Point \[green\] drawn in long\_case (location=(0.8, 0.2)); long\_right\_2 — a Point \[green\] drawn in long\_case (location=(1.8, 0.8)); long\_right\_3 — a Point \[green\] drawn in long\_case (location=(2.8, 1.3)); long\_right\_4 — a Point \[green\] drawn in long\_case (location=(0.8, 1.6)); long\_right\_5 — a Point \[green\] drawn in long\_case (location=(1.8, 2.2)); long\_right\_6 — a Point \[green\] drawn in long\_case (location=(2.8, 2.7)); long\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0)); long\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2)); long\_cut — a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True); large\_outline — a Circle \[gray\] drawn in size\_case (center=(-1.0, 0.0), radius=2.0); small\_outline — a Circle \[gray\] drawn in size\_case (center=(2.1, 0.0), radius=0.7)

Actions:
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_2 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_3 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_4 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_5 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_6 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_7 is shown on the screen, written out.
- [06:43.978](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=403.9785): large\_kept\_8 is shown on the screen, written out.
- [06:48.25](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=408.2505): size\_centre\_1 is shown on the screen, written out.
- [06:48.25](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=408.2505): size\_centre\_2 is shown on the screen, written out.
- [06:51.456](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=411.45550000000003): size\_boundary is shown on the screen, written out.
- [06:51.932](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=411.9315): large\_stolen is shown on the screen, written out.
- [06:51.932](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=411.9315): large\_stolen\_2 is shown on the screen, written out.
- [06:53.464](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=413.4635): small\_assigned is shown on the screen, written out.
- [06:53.464](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=413.4635): small\_assigned\_2 is shown on the screen, written out.
- [06:53.464](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=413.4635): small\_assigned\_3 is shown on the screen, written out.
- [06:53.464](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=413.4635): small\_assigned\_4 is shown on the screen, written out.
- [06:53.464](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=413.4635): small\_assigned\_5 is shown on the screen, written out.

##### [06:55.305](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=415.3055)

Narration: The result is mathematically consistent with the objective, but unfair to the smaller group as a density. K-means does not model cluster population or variance separately.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; size\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); caption\_size — a Tex \[text\] that says "Very different sizes"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False); long\_left — a Point \[red\] drawn in long\_case (location=(-3.0, -1.9)); long\_left\_2 — a Point \[red\] drawn in long\_case (location=(-2.1, -1.4)); long\_left\_3 — a Point \[red\] drawn in long\_case (location=(-1.2, -0.9)); long\_left\_4 — a Point \[red\] drawn in long\_case (location=(-0.2, -0.3)); long\_left\_5 — a Point \[red\] drawn in long\_case (location=(-3.0, -0.5)); long\_left\_6 — a Point \[red\] drawn in long\_case (location=(-2.1, 0.0)); long\_left\_7 — a Point \[red\] drawn in long\_case (location=(-1.2, 0.5)); long\_left\_8 — a Point \[red\] drawn in long\_case (location=(-0.2, 1.1)); long\_right — a Point \[green\] drawn in long\_case (location=(0.8, 0.2)); long\_right\_2 — a Point \[green\] drawn in long\_case (location=(1.8, 0.8)); long\_right\_3 — a Point \[green\] drawn in long\_case (location=(2.8, 1.3)); long\_right\_4 — a Point \[green\] drawn in long\_case (location=(0.8, 1.6)); long\_right\_5 — a Point \[green\] drawn in long\_case (location=(1.8, 2.2)); long\_right\_6 — a Point \[green\] drawn in long\_case (location=(2.8, 2.7)); long\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0)); long\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2)); long\_cut — a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True); large\_outline — a Circle \[gray\] drawn in size\_case (center=(-1.0, 0.0), radius=2.0); small\_outline — a Circle \[gray\] drawn in size\_case (center=(2.1, 0.0), radius=0.7); large\_kept — a Point \[blue\] drawn in size\_case (location=(-2.8, -0.2)); large\_kept\_2 — a Point \[blue\] drawn in size\_case (location=(-2.2, 1.0)); large\_kept\_3 — a Point \[blue\] drawn in size\_case (location=(-2.0, -1.2)); large\_kept\_4 — a Point \[blue\] drawn in size\_case (location=(-1.5, 0.3)); large\_kept\_5 — a Point \[blue\] drawn in size\_case (location=(-1.0, 1.5)); large\_kept\_6 — a Point \[blue\] drawn in size\_case (location=(-0.8, -1.4)); large\_kept\_7 — a Point \[blue\] drawn in size\_case (location=(-0.3, 0.7)); large\_kept\_8 — a Point \[blue\] drawn in size\_case (location=(0.1, -0.5)); large\_stolen — a Point \[red\] drawn in size\_case (location=(0.6, 0.4)); large\_stolen\_2 — a Point \[red\] drawn in size\_case (location=(0.9, -0.9)); small\_assigned — a Point \[red\] drawn in size\_case (location=(1.7, -0.2)); small\_assigned\_2 — a Point \[red\] drawn in size\_case (location=(1.9, 0.3)); small\_assigned\_3 — a Point \[red\] drawn in size\_case (location=(2.1, -0.4)); small\_assigned\_4 — a Point \[red\] drawn in size\_case (location=(2.3, 0.2)); small\_assigned\_5 — a Point \[red\] drawn in size\_case (location=(2.5, -0.1)); size\_centre\_1 — a Point \[blue\] labelled "mu\_1" drawn in size\_case (location=(-1.2, 0.1)); size\_centre\_2 — a Point \[red\] labelled "mu\_2" drawn in size\_case (location=(1.7, -0.2)); size\_boundary — a Line \[yellow\] drawn in size\_case (start=(0.35, -2.4), end=(0.35, 2.4), dashed=True)

Actions:
- [06:59.101](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=419.1015): large\_stolen is indicated — a transient flash.
- [06:59.101](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=419.1015): large\_stolen\_2 is indicated — a transient flash.

##### [07:7.155](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=427.15549999999996)

Narration: Third, this is one connected cloud without three clear density peaks. We nevertheless request k equals three.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [07:7.503](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=427.5035): forced\_case is shown on the screen, written out.
- [07:9.014](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=429.0135): caption\_forced is shown on the screen, written out.
- [07:9.454](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=429.4545): forced\_outline is shown on the screen, written out.

##### [07:15.395](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=435.395)

Narration: K-means does not answer that the data contains one group. It returns exactly three nonempty partitions because three centres were requested.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; size\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); caption\_size — a Tex \[text\] that says "Very different sizes"; forced\_case — a Figure (x\_range=(-3.2, 3.2), y\_range=(-3.2, 3.2), aspect=(1.0, 1.0)); caption\_forced — a Tex \[text\] that says "One cloud, but k equals three"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False); long\_left — a Point \[red\] drawn in long\_case (location=(-3.0, -1.9)); long\_left\_2 — a Point \[red\] drawn in long\_case (location=(-2.1, -1.4)); long\_left\_3 — a Point \[red\] drawn in long\_case (location=(-1.2, -0.9)); long\_left\_4 — a Point \[red\] drawn in long\_case (location=(-0.2, -0.3)); long\_left\_5 — a Point \[red\] drawn in long\_case (location=(-3.0, -0.5)); long\_left\_6 — a Point \[red\] drawn in long\_case (location=(-2.1, 0.0)); long\_left\_7 — a Point \[red\] drawn in long\_case (location=(-1.2, 0.5)); long\_left\_8 — a Point \[red\] drawn in long\_case (location=(-0.2, 1.1)); long\_right — a Point \[green\] drawn in long\_case (location=(0.8, 0.2)); long\_right\_2 — a Point \[green\] drawn in long\_case (location=(1.8, 0.8)); long\_right\_3 — a Point \[green\] drawn in long\_case (location=(2.8, 1.3)); long\_right\_4 — a Point \[green\] drawn in long\_case (location=(0.8, 1.6)); long\_right\_5 — a Point \[green\] drawn in long\_case (location=(1.8, 2.2)); long\_right\_6 — a Point \[green\] drawn in long\_case (location=(2.8, 2.7)); long\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0)); long\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2)); long\_cut — a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True); large\_outline — a Circle \[gray\] drawn in size\_case (center=(-1.0, 0.0), radius=2.0); small\_outline — a Circle \[gray\] drawn in size\_case (center=(2.1, 0.0), radius=0.7); large\_kept — a Point \[blue\] drawn in size\_case (location=(-2.8, -0.2)); large\_kept\_2 — a Point \[blue\] drawn in size\_case (location=(-2.2, 1.0)); large\_kept\_3 — a Point \[blue\] drawn in size\_case (location=(-2.0, -1.2)); large\_kept\_4 — a Point \[blue\] drawn in size\_case (location=(-1.5, 0.3)); large\_kept\_5 — a Point \[blue\] drawn in size\_case (location=(-1.0, 1.5)); large\_kept\_6 — a Point \[blue\] drawn in size\_case (location=(-0.8, -1.4)); large\_kept\_7 — a Point \[blue\] drawn in size\_case (location=(-0.3, 0.7)); large\_kept\_8 — a Point \[blue\] drawn in size\_case (location=(0.1, -0.5)); large\_stolen — a Point \[red\] drawn in size\_case (location=(0.6, 0.4)); large\_stolen\_2 — a Point \[red\] drawn in size\_case (location=(0.9, -0.9)); small\_assigned — a Point \[red\] drawn in size\_case (location=(1.7, -0.2)); small\_assigned\_2 — a Point \[red\] drawn in size\_case (location=(1.9, 0.3)); small\_assigned\_3 — a Point \[red\] drawn in size\_case (location=(2.1, -0.4)); small\_assigned\_4 — a Point \[red\] drawn in size\_case (location=(2.3, 0.2)); small\_assigned\_5 — a Point \[red\] drawn in size\_case (location=(2.5, -0.1)); size\_centre\_1 — a Point \[blue\] labelled "mu\_1" drawn in size\_case (location=(-1.2, 0.1)); size\_centre\_2 — a Point \[red\] labelled "mu\_2" drawn in size\_case (location=(1.7, -0.2)); size\_boundary — a Line \[yellow\] drawn in size\_case (start=(0.35, -2.4), end=(0.35, 2.4), dashed=True); forced\_outline — a Circle \[gray\] drawn in forced\_case (radius=2.5)

Actions:
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_red is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_red\_2 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_red\_3 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_red\_4 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_red\_5 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_green is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_green\_2 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_green\_3 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_green\_4 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_blue is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_blue\_2 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_blue\_3 is shown on the screen, written out.
- [07:21.258](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=441.25849999999997): forced\_blue\_4 is shown on the screen, written out.
- [07:23.603](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=443.6035): forced\_centres is shown on the screen, written out.
- [07:23.603](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=443.6035): forced\_centres\_2 is shown on the screen, written out.
- [07:23.603](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=443.6035): forced\_centres\_3 is shown on the screen, written out.

##### [07:25.736](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=445.7365)

Narration: This is not a software defect. The value k is an input to the problem, not a conclusion reached by the algorithm. A tidy colour map does not prove that the corresponding groups exist.

Board: long\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-2.8, 3.2), aspect=(8.0, 6.0)); caption\_long — a Tex \[text\] that says "Elongated groups"; size\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); caption\_size — a Tex \[text\] that says "Very different sizes"; forced\_case — a Figure (x\_range=(-3.2, 3.2), y\_range=(-3.2, 3.2), aspect=(1.0, 1.0)); caption\_forced — a Tex \[text\] that says "One cloud, but k equals three"; heading — a Heading that says "Three Ways the Geometry Can Mislead"; long\_outline\_1 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 1.1673607282593166), (2.8250451244373482, …, filled=False); long\_outline\_2 — a Polygon \[gray\] drawn in long\_case (vertices=((2.890483548894609, 2.5673607282593167), (2.8250451244373482, …, filled=False); long\_left — a Point \[red\] drawn in long\_case (location=(-3.0, -1.9)); long\_left\_2 — a Point \[red\] drawn in long\_case (location=(-2.1, -1.4)); long\_left\_3 — a Point \[red\] drawn in long\_case (location=(-1.2, -0.9)); long\_left\_4 — a Point \[red\] drawn in long\_case (location=(-0.2, -0.3)); long\_left\_5 — a Point \[red\] drawn in long\_case (location=(-3.0, -0.5)); long\_left\_6 — a Point \[red\] drawn in long\_case (location=(-2.1, 0.0)); long\_left\_7 — a Point \[red\] drawn in long\_case (location=(-1.2, 0.5)); long\_left\_8 — a Point \[red\] drawn in long\_case (location=(-0.2, 1.1)); long\_right — a Point \[green\] drawn in long\_case (location=(0.8, 0.2)); long\_right\_2 — a Point \[green\] drawn in long\_case (location=(1.8, 0.8)); long\_right\_3 — a Point \[green\] drawn in long\_case (location=(2.8, 1.3)); long\_right\_4 — a Point \[green\] drawn in long\_case (location=(0.8, 1.6)); long\_right\_5 — a Point \[green\] drawn in long\_case (location=(1.8, 2.2)); long\_right\_6 — a Point \[green\] drawn in long\_case (location=(2.8, 2.7)); long\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in long\_case (location=(-2.0, 0.0)); long\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in long\_case (location=(1.6, 1.2)); long\_cut — a Line \[yellow\] drawn in long\_case (start=(-0.2, -2.2), end=(-0.2, 3.0), dashed=True); large\_outline — a Circle \[gray\] drawn in size\_case (center=(-1.0, 0.0), radius=2.0); small\_outline — a Circle \[gray\] drawn in size\_case (center=(2.1, 0.0), radius=0.7); large\_kept — a Point \[blue\] drawn in size\_case (location=(-2.8, -0.2)); large\_kept\_2 — a Point \[blue\] drawn in size\_case (location=(-2.2, 1.0)); large\_kept\_3 — a Point \[blue\] drawn in size\_case (location=(-2.0, -1.2)); large\_kept\_4 — a Point \[blue\] drawn in size\_case (location=(-1.5, 0.3)); large\_kept\_5 — a Point \[blue\] drawn in size\_case (location=(-1.0, 1.5)); large\_kept\_6 — a Point \[blue\] drawn in size\_case (location=(-0.8, -1.4)); large\_kept\_7 — a Point \[blue\] drawn in size\_case (location=(-0.3, 0.7)); large\_kept\_8 — a Point \[blue\] drawn in size\_case (location=(0.1, -0.5)); large\_stolen — a Point \[red\] drawn in size\_case (location=(0.6, 0.4)); large\_stolen\_2 — a Point \[red\] drawn in size\_case (location=(0.9, -0.9)); small\_assigned — a Point \[red\] drawn in size\_case (location=(1.7, -0.2)); small\_assigned\_2 — a Point \[red\] drawn in size\_case (location=(1.9, 0.3)); small\_assigned\_3 — a Point \[red\] drawn in size\_case (location=(2.1, -0.4)); small\_assigned\_4 — a Point \[red\] drawn in size\_case (location=(2.3, 0.2)); small\_assigned\_5 — a Point \[red\] drawn in size\_case (location=(2.5, -0.1)); size\_centre\_1 — a Point \[blue\] labelled "mu\_1" drawn in size\_case (location=(-1.2, 0.1)); size\_centre\_2 — a Point \[red\] labelled "mu\_2" drawn in size\_case (location=(1.7, -0.2)); size\_boundary — a Line \[yellow\] drawn in size\_case (start=(0.35, -2.4), end=(0.35, 2.4), dashed=True); forced\_outline — a Circle \[gray\] drawn in forced\_case (radius=2.5); forced\_red — a Point \[red\] drawn in forced\_case (location=(-2.1, -0.6)); forced\_red\_2 — a Point \[red\] drawn in forced\_case (location=(-1.8, 0.8)); forced\_red\_3 — a Point \[red\] drawn in forced\_case (location=(-1.3, -1.4)); forced\_red\_4 — a Point \[red\] drawn in forced\_case (location=(-1.0, 0.1)); forced\_red\_5 — a Point \[red\] drawn in forced\_case (location=(-0.7, 1.6)); forced\_green — a Point \[green\] drawn in forced\_case (location=(-0.2, -0.9)); forced\_green\_2 — a Point \[green\] drawn in forced\_case (location=(0.0, 0.5)); forced\_green\_3 — a Point \[green\] drawn in forced\_case (location=(0.4, 1.8)); forced\_green\_4 — a Point \[green\] drawn in forced\_case (location=(0.7, -1.7)); forced\_blue — a Point \[blue\] drawn in forced\_case (location=(1.0, -0.2)); forced\_blue\_2 — a Point \[blue\] drawn in forced\_case (location=(1.4, 1.0)); forced\_blue\_3 — a Point \[blue\] drawn in forced\_case (location=(1.8, -1.0)); forced\_blue\_4 — a Point \[blue\] drawn in forced\_case (location=(2.1, 0.3)); forced\_centres — a Point \[red\] labelled "mu\_1" drawn in forced\_case (location=(-1.5, 0.0)); forced\_centres\_2 — a Point \[green\] labelled "mu\_2" drawn in forced\_case (location=(0.1, 0.2)); forced\_centres\_3 — a Point \[blue\] labelled "mu\_3" drawn in forced\_case (location=(1.5, 0.0))

Actions:
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): caption\_forced is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): caption\_long is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): caption\_size is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_case is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_outline is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_red is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_red\_2 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_red\_3 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_red\_4 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_red\_5 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_green is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_green\_2 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_green\_3 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_green\_4 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_blue is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_blue\_2 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_blue\_3 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_blue\_4 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_centres is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_centres\_2 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): forced\_centres\_3 is hidden from the screen — forced\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): heading is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_case is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_outline\_1 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_outline\_2 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_2 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_3 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_4 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_5 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_6 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_7 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_left\_8 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right\_2 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right\_3 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right\_4 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right\_5 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_right\_6 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_centre\_1 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_centre\_2 is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): long\_cut is hidden from the screen — long\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): size\_case is hidden from the screen — left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_outline is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_outline is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_2 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_3 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_4 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_5 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_6 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_7 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_kept\_8 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_stolen is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): large\_stolen\_2 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_assigned is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_assigned\_2 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_assigned\_3 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_assigned\_4 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): small\_assigned\_5 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): size\_centre\_1 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): size\_centre\_2 is hidden from the screen — size\_case left the board.
- [07:37.95](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=457.95): size\_boundary is hidden from the screen — size\_case left the board.

##### [07:39.15](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=459.15)

Narration: Before believing a k-means result, ask whether compact clusters are plausible in the scaled feature space, and whether their spreads and populations are comparable.

Board: Empty.

Actions:
- [07:39.15](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=459.15): diagnostic\_heading is shown on the screen, written out.
- [07:42.876](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=462.87649999999996): diagnostic\_1 is shown on the screen, written out.
- [07:47.265](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=467.2655): diagnostic\_2 is shown on the screen, written out.

##### [07:50.373](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=470.373)

Narration: Then test stability across initializations and resampled data. Finally, ask what k means in the business or scientific setting. If it has no interpretation, treat it as a modelling choice to validate, not a fact discovered by the colours.

Board: diagnostic\_1 — a Text \[text\] that says "Are groups roughly compact in the chosen feature scale?"; diagnostic\_2 — a Text \[text\] that says "Are their spreads and populations comparable?"; diagnostic\_heading — a Heading that says "Questions to Ask Before Believing the Colours"

Actions:
- [07:51.371](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=471.37149999999997): diagnostic\_3 is shown on the screen, written out.
- [07:57.397](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=477.3975): diagnostic\_4 is shown on the screen, written out.
- [08:6.888](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=486.8882708333333): diagnostic\_1 is hidden from the screen — left the board.
- [08:6.888](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=486.8882708333333): diagnostic\_2 is hidden from the screen — left the board.
- [08:6.888](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=486.8882708333333): diagnostic\_3 is hidden from the screen — left the board.
- [08:6.888](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=486.8882708333333): diagnostic\_4 is hidden from the screen — left the board.
- [08:6.888](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=486.8882708333333): diagnostic\_heading is hidden from the screen — left the board.

### Scene 5: [From Soft Membership to Mixtures](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994)

Span: 08:7.93–11:22.489 (487.92993749999994s–682.4885416666666s).

#### Objects

- compare\_heading: a Heading that says "Return to the Elongated Case"
- density: a Math \[text\] that says "$p(x\_i) = sum\_j pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j)$"
- e\_step: a Text \[text\] that says "E step: compute every responsibility from the current parameters."
- em\_heading: a Heading that says "Fit by Alternating Two Weighted Steps"
- em\_stop: a Text \[text\] that says "Repeat until the log likelihood stops improving materially."
- g\_case: a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0))
- g\_ellipse\_a: a Polygon \[red\] drawn in g\_case (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False)
- g\_ellipse\_b: a Polygon \[green\] drawn in g\_case (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False)
- g\_label: a Tex \[text\] that says "Gaussian mixture: fitted ellipses"
- g\_points\_a: a Point \[red\] drawn in g\_case (location=(-3.0, -1.8))
- g\_points\_a\_2: a Point \[red\] drawn in g\_case (location=(-2.1, -1.3))
- g\_points\_a\_3: a Point \[red\] drawn in g\_case (location=(-1.2, -0.9))
- g\_points\_a\_4: a Point \[red\] drawn in g\_case (location=(-0.3, -0.4))
- g\_points\_a\_5: a Point \[red\] drawn in g\_case (location=(0.6, 0.1))
- g\_points\_a\_6: a Point \[red\] drawn in g\_case (location=(1.5, 0.6))
- g\_points\_a\_7: a Point \[red\] drawn in g\_case (location=(2.5, 1.2))
- g\_points\_b: a Point \[green\] drawn in g\_case (location=(-2.8, -0.3))
- g\_points\_b\_2: a Point \[green\] drawn in g\_case (location=(-1.9, 0.2))
- g\_points\_b\_3: a Point \[green\] drawn in g\_case (location=(-1.0, 0.7))
- g\_points\_b\_4: a Point \[green\] drawn in g\_case (location=(-0.1, 1.2))
- g\_points\_b\_5: a Point \[green\] drawn in g\_case (location=(0.8, 1.7))
- g\_points\_b\_6: a Point \[green\] drawn in g\_case (location=(1.7, 2.2))
- g\_points\_b\_7: a Point \[green\] drawn in g\_case (location=(2.6, 2.7))
- gmm\_ellipse\_a: a Polygon \[red\] drawn in gmm\_plot (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False)
- gmm\_ellipse\_b: a Polygon \[green\] drawn in gmm\_plot (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False)
- gmm\_mean\_a: a Point \[red\] labelled "mu\_1" drawn in gmm\_plot (location=(-0.2, -0.3))
- gmm\_mean\_b: a Point \[green\] labelled "mu\_2" drawn in gmm\_plot (location=(-0.1, 1.2))
- gmm\_plot: an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False)
- gmm\_points\_a: a Point \[red\] drawn in gmm\_plot (location=(-3.0, -1.8))
- gmm\_points\_a\_2: a Point \[red\] drawn in gmm\_plot (location=(-2.1, -1.3))
- gmm\_points\_a\_3: a Point \[red\] drawn in gmm\_plot (location=(-1.2, -0.9))
- gmm\_points\_a\_4: a Point \[red\] drawn in gmm\_plot (location=(-0.3, -0.4))
- gmm\_points\_a\_5: a Point \[red\] drawn in gmm\_plot (location=(0.6, 0.1))
- gmm\_points\_a\_6: a Point \[red\] drawn in gmm\_plot (location=(1.5, 0.6))
- gmm\_points\_a\_7: a Point \[red\] drawn in gmm\_plot (location=(2.5, 1.2))
- gmm\_points\_b: a Point \[green\] drawn in gmm\_plot (location=(-2.8, -0.3))
- gmm\_points\_b\_2: a Point \[green\] drawn in gmm\_plot (location=(-1.9, 0.2))
- gmm\_points\_b\_3: a Point \[green\] drawn in gmm\_plot (location=(-1.0, 0.7))
- gmm\_points\_b\_4: a Point \[green\] drawn in gmm\_plot (location=(-0.1, 1.2))
- gmm\_points\_b\_5: a Point \[green\] drawn in gmm\_plot (location=(0.8, 1.7))
- gmm\_points\_b\_6: a Point \[green\] drawn in gmm\_plot (location=(1.7, 2.2))
- gmm\_points\_b\_7: a Point \[green\] drawn in gmm\_plot (location=(2.6, 2.7))
- k\_boundary: a Line \[yellow\] drawn in k\_case (start=(0.0, -2.5), end=(0.0, 3.0), dashed=True)
- k\_case: a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0))
- k\_label: a Tex \[text\] that says "K-means: nearest-centre cells"
- k\_left: a Point \[red\] drawn in k\_case (location=(-3.0, -1.8))
- k\_left\_2: a Point \[red\] drawn in k\_case (location=(-2.1, -1.3))
- k\_left\_3: a Point \[red\] drawn in k\_case (location=(-1.2, -0.9))
- k\_left\_4: a Point \[red\] drawn in k\_case (location=(-0.3, -0.4))
- k\_left\_5: a Point \[red\] drawn in k\_case (location=(-2.8, -0.3))
- k\_left\_6: a Point \[red\] drawn in k\_case (location=(-1.9, 0.2))
- k\_left\_7: a Point \[red\] drawn in k\_case (location=(-1.0, 0.7))
- k\_left\_8: a Point \[red\] drawn in k\_case (location=(-0.1, 1.2))
- k\_outline\_a: a Polygon \[gray\] drawn in k\_case (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False)
- k\_outline\_b: a Polygon \[gray\] drawn in k\_case (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False)
- k\_right: a Point \[green\] drawn in k\_case (location=(0.6, 0.1))
- k\_right\_2: a Point \[green\] drawn in k\_case (location=(1.5, 0.6))
- k\_right\_3: a Point \[green\] drawn in k\_case (location=(2.5, 1.2))
- k\_right\_4: a Point \[green\] drawn in k\_case (location=(0.8, 1.7))
- k\_right\_5: a Point \[green\] drawn in k\_case (location=(1.7, 2.2))
- k\_right\_6: a Point \[green\] drawn in k\_case (location=(2.6, 2.7))
- m\_step: a Text \[text\] that says "M step: update weights, means, and covariances using those responsibilities."
- parameter\_heading: a Heading that says "What the Extra Parameters Do"
- parameters: a Block \[text\] that says "$pi\_j$: the component's expected population share. $mu\_j$: the component's centre. $Sigma\_j$: its spread, elongation, and orientation."
- probabilities: a Table \[text\] that says "Component Responsibility 1 0.35 2 0.65" (rows=(('Component', 'Responsibility'), ('1', '0.35'), ('2', '0.65')), header=True)
- responsibility: a Math \[text\] that says "$r\_(i j) = frac(pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j), sum\_l pi\_l upright("Normal")(x\_i \| mu\_l, Sigma\_l))$"
- soft\_centre\_1: a Point \[red\] labelled "mu\_1" drawn in soft\_plot (location=(-1.8, 0.1))
- soft\_centre\_2: a Point \[green\] labelled "mu\_2" drawn in soft\_plot (location=(1.8, 0.1))
- soft\_cloud\_1: a Point \[red\] drawn in soft\_plot (location=(-2.8, -0.5))
- soft\_cloud\_1\_2: a Point \[red\] drawn in soft\_plot (location=(-2.2, 0.5))
- soft\_cloud\_1\_3: a Point \[red\] drawn in soft\_plot (location=(-1.7, -0.2))
- soft\_cloud\_1\_4: a Point \[red\] drawn in soft\_plot (location=(-1.2, 0.8))
- soft\_cloud\_2: a Point \[green\] drawn in soft\_plot (location=(1.0, -0.5))
- soft\_cloud\_2\_2: a Point \[green\] drawn in soft\_plot (location=(1.5, 0.6))
- soft\_cloud\_2\_3: a Point \[green\] drawn in soft\_plot (location=(2.1, -0.2))
- soft\_cloud\_2\_4: a Point \[green\] drawn in soft\_plot (location=(2.7, 0.7))
- soft\_definition: a Panel that says "The responsibility $r\_(i j)$ is the conditional probability that component $j$ generated observation $i$, under the current fitted model."
- soft\_heading: a Heading that says "Replace a Label with Responsibilities"
- soft\_link\_1: a Line \[gray\] drawn in soft\_plot (start=(0.2, 0.2), end=(-1.8, 0.1), dashed=True)
- soft\_link\_2: a Line \[gray\] drawn in soft\_plot (start=(0.2, 0.2), end=(1.8, 0.1), dashed=True)
- soft\_observation: a Point \[yellow\] labelled "x\_i" drawn in soft\_plot (location=(0.2, 0.2))
- soft\_plot: an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False)

#### Beats

##### [08:7.93](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994)

Narration: To relax hard assignment, keep one membership number for every component. For observation i and component j, call that number the responsibility r i j.

Board: Empty.

Actions:
- [08:7.93](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994): soft\_heading is shown on the screen, written out.
- [08:7.93](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=487.92993749999994): soft\_plot is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_1 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_1\_2 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_1\_3 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_1\_4 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_2 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_2\_2 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_2\_3 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_cloud\_2\_4 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_centre\_1 is shown on the screen, written out.
- [08:11.773](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=491.77293749999995): soft\_centre\_2 is shown on the screen, written out.
- [08:17.16](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=497.15993749999996): soft\_plot moves to a new place on the board.
- [08:17.16](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=497.15993749999996): soft\_definition is shown on the screen, written out.

##### [08:20.372](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=500.37193749999994)

Narration: Consider this observation near the overlap. A hard rule must choose one side. The mixture instead evaluates how plausible the observation is under both fitted components.

Board: soft\_definition — a Panel that says "The responsibility $r\_(i j)$ is the conditional probability that component $j$ generated observation $i$, under the current fitted model."; soft\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); soft\_heading — a Heading that says "Replace a Label with Responsibilities"; soft\_cloud\_1 — a Point \[red\] drawn in soft\_plot (location=(-2.8, -0.5)); soft\_cloud\_1\_2 — a Point \[red\] drawn in soft\_plot (location=(-2.2, 0.5)); soft\_cloud\_1\_3 — a Point \[red\] drawn in soft\_plot (location=(-1.7, -0.2)); soft\_cloud\_1\_4 — a Point \[red\] drawn in soft\_plot (location=(-1.2, 0.8)); soft\_cloud\_2 — a Point \[green\] drawn in soft\_plot (location=(1.0, -0.5)); soft\_cloud\_2\_2 — a Point \[green\] drawn in soft\_plot (location=(1.5, 0.6)); soft\_cloud\_2\_3 — a Point \[green\] drawn in soft\_plot (location=(2.1, -0.2)); soft\_cloud\_2\_4 — a Point \[green\] drawn in soft\_plot (location=(2.7, 0.7)); soft\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in soft\_plot (location=(-1.8, 0.1)); soft\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in soft\_plot (location=(1.8, 0.1))

Actions:
- [08:21.417](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=501.41693749999996): soft\_observation is shown on the screen, written out.
- [08:28.708](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=508.70793749999996): responsibility is shown on the screen, written out.
- [08:30.496](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=510.49593749999997): soft\_link\_1 is shown on the screen, written out.
- [08:30.496](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=510.49593749999997): soft\_link\_2 is shown on the screen, written out.
- [08:32.203](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=512.2029375): responsibility moves to a new place on the board.
- [08:32.203](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=512.2029375): soft\_definition is hidden from the screen — left the board.

##### [08:32.803](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=512.8029375)

Narration: Suppose the resulting responsibilities are zero point three five and zero point six five. The second component is more plausible, but the first remains credible. The two values add to one.

Board: responsibility — a Math \[text\] that says "$r\_(i j) = frac(pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j), sum\_l pi\_l upright("Normal")(x\_i \| mu\_l, Sigma\_l))$"; soft\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); soft\_heading — a Heading that says "Replace a Label with Responsibilities"; soft\_cloud\_1 — a Point \[red\] drawn in soft\_plot (location=(-2.8, -0.5)); soft\_cloud\_1\_2 — a Point \[red\] drawn in soft\_plot (location=(-2.2, 0.5)); soft\_cloud\_1\_3 — a Point \[red\] drawn in soft\_plot (location=(-1.7, -0.2)); soft\_cloud\_1\_4 — a Point \[red\] drawn in soft\_plot (location=(-1.2, 0.8)); soft\_cloud\_2 — a Point \[green\] drawn in soft\_plot (location=(1.0, -0.5)); soft\_cloud\_2\_2 — a Point \[green\] drawn in soft\_plot (location=(1.5, 0.6)); soft\_cloud\_2\_3 — a Point \[green\] drawn in soft\_plot (location=(2.1, -0.2)); soft\_cloud\_2\_4 — a Point \[green\] drawn in soft\_plot (location=(2.7, 0.7)); soft\_centre\_1 — a Point \[red\] labelled "mu\_1" drawn in soft\_plot (location=(-1.8, 0.1)); soft\_centre\_2 — a Point \[green\] labelled "mu\_2" drawn in soft\_plot (location=(1.8, 0.1)); soft\_observation — a Point \[yellow\] labelled "x\_i" drawn in soft\_plot (location=(0.2, 0.2)); soft\_link\_1 — a Line \[gray\] drawn in soft\_plot (start=(0.2, 0.2), end=(-1.8, 0.1), dashed=True); soft\_link\_2 — a Line \[gray\] drawn in soft\_plot (start=(0.2, 0.2), end=(1.8, 0.1), dashed=True)

Actions:
- [08:34.231](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=514.2309375): probabilities is shown on the screen, written out.
- [08:35.972](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=515.9719375): probabilities is shown on the screen, written out.
- [08:37.563](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=517.5629375): probabilities is shown on the screen, written out.
- [08:44.111](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=524.1109375): probabilities (the "column=2" part) is emphasized.
- [08:45.863](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=525.8634374999999): probabilities (the "column=2" part) is no longer emphasized.

##### [08:46.463](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=526.4634374999999)

Narration: These are model-based probabilities, not calibrated truth supplied by the data. They depend on the fitted component shapes, their population weights, and the Gaussian mixture assumptions.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): probabilities is hidden from the screen — left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): responsibility is hidden from the screen — left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_heading is hidden from the screen — left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_plot is hidden from the screen — left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_1 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_1\_2 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_1\_3 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_1\_4 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_2 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_2\_2 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_2\_3 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_cloud\_2\_4 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_centre\_1 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_centre\_2 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_observation is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_link\_1 is hidden from the screen — soft\_plot left the board.
- [08:58.352](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=538.3524375): soft\_link\_2 is hidden from the screen — soft\_plot left the board.

##### [08:59.552](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=539.5524374999999)

Narration: A Gaussian mixture says that the observed density is a weighted sum of Gaussian component densities. The extra parameters each answer a distinct question.

Board: Empty.

Actions:
- [08:59.552](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=539.5524374999999): parameter\_heading is shown on the screen, written out.
- [09:3.105](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=543.1049374999999): density is shown on the screen, written out.
- [09:4.986](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=544.9859375): gmm\_plot is shown on the screen, written out.

##### [09:10.683](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=550.6829375)

Narration: The mixture weight pi records the expected share of observations generated by a component. Unlike k-means, the model can explicitly represent one large component and one small component.

Board: density — a Math \[text\] that says "$p(x\_i) = sum\_j pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j)$"; gmm\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); parameter\_heading — a Heading that says "What the Extra Parameters Do"

Actions:
- [09:11.589](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=551.5889374999999): parameters is shown on the screen, written out.
- [09:11.867](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=551.8669375): parameters (the "$pi\_j$" part) is emphasized.
- [09:23.373](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=563.3729374999999): parameters (the "$pi\_j$" part) is no longer emphasized.

##### [09:23.973](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=563.9729375)

Narration: The mean mu gives location, much like a k-means centre. Here the two means sit near the middle of their respective densities.

Board: parameters — a Block \[text\] that says "$pi\_j$: the component's expected population share. $mu\_j$: the component's centre. $Sigma\_j$: its spread, elongation, and orientation."; density — a Math \[text\] that says "$p(x\_i) = sum\_j pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j)$"; gmm\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); parameter\_heading — a Heading that says "What the Extra Parameters Do"

Actions:
- [09:24.96](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=564.9599374999999): parameters (the "$mu\_j$" part) is emphasized.
- [09:29.499](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=569.4989374999999): gmm\_mean\_a is shown on the screen, written out.
- [09:29.499](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=569.4989374999999): gmm\_mean\_b is shown on the screen, written out.
- [09:33.028](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=573.0284374999999): parameters (the "$mu\_j$" part) is no longer emphasized.

##### [09:33.628](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=573.6284374999999)

Narration: The covariance matrix Sigma is the crucial addition. Its overall scale controls spread. Its unequal directional variances create elongation, and its off-diagonal relationship rotates that elongation.

Board: parameters — a Block \[text\] that says "$pi\_j$: the component's expected population share. $mu\_j$: the component's centre. $Sigma\_j$: its spread, elongation, and orientation."; density — a Math \[text\] that says "$p(x\_i) = sum\_j pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j)$"; gmm\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); parameter\_heading — a Heading that says "What the Extra Parameters Do"; gmm\_mean\_a — a Point \[red\] labelled "mu\_1" drawn in gmm\_plot (location=(-0.2, -0.3)); gmm\_mean\_b — a Point \[green\] labelled "mu\_2" drawn in gmm\_plot (location=(-0.1, 1.2))

Actions:
- [09:34.209](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=574.2089374999999): gmm\_ellipse\_a is shown on the screen, written out.
- [09:34.209](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=574.2089374999999): gmm\_ellipse\_b is shown on the screen, written out.
- [09:35.3](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=575.2999374999999): parameters (the "$Sigma\_j$" part) is emphasized.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_2 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_3 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_4 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_5 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_6 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_a\_7 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_2 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_3 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_4 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_5 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_6 is shown on the screen, written out.
- [09:43.346](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=583.3459375): gmm\_points\_b\_7 is shown on the screen, written out.
- [09:48.43](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=588.4304374999999): parameters (the "$Sigma\_j$" part) is no longer emphasized.

##### [09:49.03](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=589.0304375)

Narration: These ellipses are equal-density contours. They can follow the long axes of the two groups, which is exactly the geometric freedom missing from nearest-centre k-means.

Board: parameters — a Block \[text\] that says "$pi\_j$: the component's expected population share. $mu\_j$: the component's centre. $Sigma\_j$: its spread, elongation, and orientation."; density — a Math \[text\] that says "$p(x\_i) = sum\_j pi\_j upright("Normal")(x\_i \| mu\_j, Sigma\_j)$"; gmm\_plot — an Axes (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), include\_ticks=False); parameter\_heading — a Heading that says "What the Extra Parameters Do"; gmm\_mean\_a — a Point \[red\] labelled "mu\_1" drawn in gmm\_plot (location=(-0.2, -0.3)); gmm\_mean\_b — a Point \[green\] labelled "mu\_2" drawn in gmm\_plot (location=(-0.1, 1.2)); gmm\_ellipse\_a — a Polygon \[red\] drawn in gmm\_plot (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False); gmm\_ellipse\_b — a Polygon \[green\] drawn in gmm\_plot (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False); gmm\_points\_a — a Point \[red\] drawn in gmm\_plot (location=(-3.0, -1.8)); gmm\_points\_a\_2 — a Point \[red\] drawn in gmm\_plot (location=(-2.1, -1.3)); gmm\_points\_a\_3 — a Point \[red\] drawn in gmm\_plot (location=(-1.2, -0.9)); gmm\_points\_a\_4 — a Point \[red\] drawn in gmm\_plot (location=(-0.3, -0.4)); gmm\_points\_a\_5 — a Point \[red\] drawn in gmm\_plot (location=(0.6, 0.1)); gmm\_points\_a\_6 — a Point \[red\] drawn in gmm\_plot (location=(1.5, 0.6)); gmm\_points\_a\_7 — a Point \[red\] drawn in gmm\_plot (location=(2.5, 1.2)); gmm\_points\_b — a Point \[green\] drawn in gmm\_plot (location=(-2.8, -0.3)); gmm\_points\_b\_2 — a Point \[green\] drawn in gmm\_plot (location=(-1.9, 0.2)); gmm\_points\_b\_3 — a Point \[green\] drawn in gmm\_plot (location=(-1.0, 0.7)); gmm\_points\_b\_4 — a Point \[green\] drawn in gmm\_plot (location=(-0.1, 1.2)); gmm\_points\_b\_5 — a Point \[green\] drawn in gmm\_plot (location=(0.8, 1.7)); gmm\_points\_b\_6 — a Point \[green\] drawn in gmm\_plot (location=(1.7, 2.2)); gmm\_points\_b\_7 — a Point \[green\] drawn in gmm\_plot (location=(2.6, 2.7))

Actions:
- [09:49.693](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=589.6929375): gmm\_ellipse\_a is indicated — a transient flash.
- [09:49.693](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=589.6929375): gmm\_ellipse\_b is indicated — a transient flash.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): density is hidden from the screen — left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_plot is hidden from the screen — left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_mean\_a is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_mean\_b is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_ellipse\_a is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_ellipse\_b is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_2 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_3 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_4 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_5 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_6 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_a\_7 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_2 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_3 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_4 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_5 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_6 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): gmm\_points\_b\_7 is hidden from the screen — gmm\_plot left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): parameter\_heading is hidden from the screen — left the board.
- [09:59.897](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=599.8974374999999): parameters is hidden from the screen — left the board.

##### [10:1.097](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=601.0974375)

Narration: The usual fitting procedure alternates two weighted steps. In the E step, use the current weights, means, and covariances to compute every responsibility.

Board: Empty.

Actions:
- [10:1.097](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=601.0974375): em\_heading is shown on the screen, written out.
- [10:6.078](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=606.0779375): e\_step is shown on the screen, written out.

##### [10:12.994](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=612.9939374999999)

Narration: In the M step, treat those responsibilities as fractional counts. Update each mixture weight from its total responsibility. Update each mean as a responsibility-weighted average.

Board: e\_step — a Text \[text\] that says "E step: compute every responsibility from the current parameters."; em\_heading — a Heading that says "Fit by Alternating Two Weighted Steps"

Actions:
- [10:13.795](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=613.7949375): m\_step is shown on the screen, written out.
- [10:19.077](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=619.0769375): m\_step (the "weights" part) is emphasized.
- [10:22.874](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=622.8739374999999): m\_step (the "means" part) is emphasized.
- [10:22.874](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=622.8739374999999): m\_step (the "weights" part) is no longer emphasized.
- [10:25.509](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=625.5094374999999): m\_step (the "means" part) is no longer emphasized.

##### [10:26.109](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=626.1094374999999)

Narration: Then update each covariance from weighted deviations around that mean. Repeat the two steps until log likelihood no longer improves materially. Like k-means, this alternating fit can reach local optima, so restarts still matter.

Board: e\_step — a Text \[text\] that says "E step: compute every responsibility from the current parameters."; m\_step — a Text \[text\] that says "M step: update weights, means, and covariances using those responsibilities."; em\_heading — a Heading that says "Fit by Alternating Two Weighted Steps"

Actions:
- [10:27.421](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=627.4209374999999): m\_step (the "covariances" part) is emphasized.
- [10:30.893](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=630.8929374999999): em\_stop is shown on the screen, written out.
- [10:30.893](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=630.8929374999999): m\_step (the "covariances" part) is no longer emphasized.
- [10:42.201](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.2009374999999): e\_step is hidden from the screen — left the board.
- [10:42.201](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.2009374999999): em\_heading is hidden from the screen — left the board.
- [10:42.201](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.2009374999999): em\_stop is hidden from the screen — left the board.
- [10:42.201](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.2009374999999): m\_step is hidden from the screen — left the board.

##### [10:42.801](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.8009374999999)

Narration: Return to the elongated example. On the left, k-means uses a straight nearest-centre boundary and slices across both natural groups.

Board: Empty.

Actions:
- [10:42.801](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=642.8009374999999): compare\_heading is shown on the screen, written out.
- [10:46.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=646.4469374999999): k\_label is shown on the screen, written out.
- [10:46.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=646.4469374999999): k\_case is shown on the screen, written out.
- [10:49.442](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=649.4419374999999): k\_boundary is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_2 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_3 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_4 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_5 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_6 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_7 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_left\_8 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right\_2 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right\_3 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right\_4 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right\_5 is shown on the screen, written out.
- [10:50.057](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=650.0569374999999): k\_right\_6 is shown on the screen, written out.
- [10:51.276](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=651.2759374999999): k\_outline\_a is shown on the screen, written out.
- [10:51.276](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=651.2759374999999): k\_outline\_b is shown on the screen, written out.

##### [10:53.351](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=653.3509374999999)

Narration: On the right, the Gaussian mixture learns two covariance ellipses. Their orientations follow the groups, and observations in the overlap can retain intermediate responsibilities instead of being treated as certain.

Board: k\_label — a Tex \[text\] that says "K-means: nearest-centre cells"; k\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); compare\_heading — a Heading that says "Return to the Elongated Case"; k\_outline\_a — a Polygon \[gray\] drawn in k\_case (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False); k\_outline\_b — a Polygon \[gray\] drawn in k\_case (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False); k\_left — a Point \[red\] drawn in k\_case (location=(-3.0, -1.8)); k\_left\_2 — a Point \[red\] drawn in k\_case (location=(-2.1, -1.3)); k\_left\_3 — a Point \[red\] drawn in k\_case (location=(-1.2, -0.9)); k\_left\_4 — a Point \[red\] drawn in k\_case (location=(-0.3, -0.4)); k\_left\_5 — a Point \[red\] drawn in k\_case (location=(-2.8, -0.3)); k\_left\_6 — a Point \[red\] drawn in k\_case (location=(-1.9, 0.2)); k\_left\_7 — a Point \[red\] drawn in k\_case (location=(-1.0, 0.7)); k\_left\_8 — a Point \[red\] drawn in k\_case (location=(-0.1, 1.2)); k\_right — a Point \[green\] drawn in k\_case (location=(0.6, 0.1)); k\_right\_2 — a Point \[green\] drawn in k\_case (location=(1.5, 0.6)); k\_right\_3 — a Point \[green\] drawn in k\_case (location=(2.5, 1.2)); k\_right\_4 — a Point \[green\] drawn in k\_case (location=(0.8, 1.7)); k\_right\_5 — a Point \[green\] drawn in k\_case (location=(1.7, 2.2)); k\_right\_6 — a Point \[green\] drawn in k\_case (location=(2.6, 2.7)); k\_boundary — a Line \[yellow\] drawn in k\_case (start=(0.0, -2.5), end=(0.0, 3.0), dashed=True)

Actions:
- [10:54.256](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=654.2559375): g\_label is shown on the screen, written out.
- [10:54.256](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=654.2559375): g\_case is shown on the screen, written out.
- [10:57.368](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=657.3679374999999): g\_ellipse\_a is shown on the screen, written out.
- [10:57.368](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=657.3679374999999): g\_ellipse\_b is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_2 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_3 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_4 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_5 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_6 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_a\_7 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_2 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_3 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_4 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_5 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_6 is shown on the screen, written out.
- [10:59.957](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=659.9569374999999): g\_points\_b\_7 is shown on the screen, written out.

##### [11:7.581](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=667.5809374999999)

Narration: The gain is real, but so is the cost. More parameters require more data, covariance estimates can become unstable, and a Gaussian component can chase a tiny group unless the fit is regularized and checked.

Board: k\_label — a Tex \[text\] that says "K-means: nearest-centre cells"; k\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); g\_label — a Tex \[text\] that says "Gaussian mixture: fitted ellipses"; g\_case — a Figure (x\_range=(-4.0, 4.0), y\_range=(-3.0, 3.0), aspect=(8.0, 6.0)); compare\_heading — a Heading that says "Return to the Elongated Case"; k\_outline\_a — a Polygon \[gray\] drawn in k\_case (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False); k\_outline\_b — a Polygon \[gray\] drawn in k\_case (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False); k\_left — a Point \[red\] drawn in k\_case (location=(-3.0, -1.8)); k\_left\_2 — a Point \[red\] drawn in k\_case (location=(-2.1, -1.3)); k\_left\_3 — a Point \[red\] drawn in k\_case (location=(-1.2, -0.9)); k\_left\_4 — a Point \[red\] drawn in k\_case (location=(-0.3, -0.4)); k\_left\_5 — a Point \[red\] drawn in k\_case (location=(-2.8, -0.3)); k\_left\_6 — a Point \[red\] drawn in k\_case (location=(-1.9, 0.2)); k\_left\_7 — a Point \[red\] drawn in k\_case (location=(-1.0, 0.7)); k\_left\_8 — a Point \[red\] drawn in k\_case (location=(-0.1, 1.2)); k\_right — a Point \[green\] drawn in k\_case (location=(0.6, 0.1)); k\_right\_2 — a Point \[green\] drawn in k\_case (location=(1.5, 0.6)); k\_right\_3 — a Point \[green\] drawn in k\_case (location=(2.5, 1.2)); k\_right\_4 — a Point \[green\] drawn in k\_case (location=(0.8, 1.7)); k\_right\_5 — a Point \[green\] drawn in k\_case (location=(1.7, 2.2)); k\_right\_6 — a Point \[green\] drawn in k\_case (location=(2.6, 2.7)); k\_boundary — a Line \[yellow\] drawn in k\_case (start=(0.0, -2.5), end=(0.0, 3.0), dashed=True); g\_ellipse\_a — a Polygon \[red\] drawn in g\_case (vertices=((2.890483548894609, 1.1173607282593165), (2.834109584128165, 1…, filled=False); g\_ellipse\_b — a Polygon \[green\] drawn in g\_case (vertices=((2.990483548894609, 2.6173607282593165), (2.9341095841281652, …, filled=False); g\_points\_a — a Point \[red\] drawn in g\_case (location=(-3.0, -1.8)); g\_points\_a\_2 — a Point \[red\] drawn in g\_case (location=(-2.1, -1.3)); g\_points\_a\_3 — a Point \[red\] drawn in g\_case (location=(-1.2, -0.9)); g\_points\_a\_4 — a Point \[red\] drawn in g\_case (location=(-0.3, -0.4)); g\_points\_a\_5 — a Point \[red\] drawn in g\_case (location=(0.6, 0.1)); g\_points\_a\_6 — a Point \[red\] drawn in g\_case (location=(1.5, 0.6)); g\_points\_a\_7 — a Point \[red\] drawn in g\_case (location=(2.5, 1.2)); g\_points\_b — a Point \[green\] drawn in g\_case (location=(-2.8, -0.3)); g\_points\_b\_2 — a Point \[green\] drawn in g\_case (location=(-1.9, 0.2)); g\_points\_b\_3 — a Point \[green\] drawn in g\_case (location=(-1.0, 0.7)); g\_points\_b\_4 — a Point \[green\] drawn in g\_case (location=(-0.1, 1.2)); g\_points\_b\_5 — a Point \[green\] drawn in g\_case (location=(0.8, 1.7)); g\_points\_b\_6 — a Point \[green\] drawn in g\_case (location=(1.7, 2.2)); g\_points\_b\_7 — a Point \[green\] drawn in g\_case (location=(2.6, 2.7))

Actions:
- [11:11.517](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=671.5169374999999): g\_ellipse\_a is indicated — a transient flash.
- [11:11.717](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=671.7169374999999): g\_ellipse\_b is indicated — a transient flash.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): compare\_heading is hidden from the screen — left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_case is hidden from the screen — left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_ellipse\_a is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_ellipse\_b is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_2 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_3 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_4 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_5 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_6 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_a\_7 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_2 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_3 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_4 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_5 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_6 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_points\_b\_7 is hidden from the screen — g\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): g\_label is hidden from the screen — left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_case is hidden from the screen — left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_outline\_a is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_outline\_b is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_2 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_3 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_4 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_5 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_6 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_7 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_left\_8 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right\_2 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right\_3 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right\_4 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right\_5 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_right\_6 is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_boundary is hidden from the screen — k\_case left the board.
- [11:21.447](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=681.4468749999999): k\_label is hidden from the screen — left the board.

### Scene 6: [Choose and Check](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666)

Span: 11:22.489–13:42.64 (682.4885416666666s–822.6397916666666s).

#### Objects

- comparison: a Table \[text\] that says "Model Membership Geometry Main fit criterion K-means hard compact cells squared distance Gaussian mixture probabilistic covariance ellipses likelihood" (rows=(('Model', 'Membership', 'Geometry', 'Main fit criterion'), ('K…, header=True)
- comparison\_heading: a Heading that says "What Each Model Is Claiming"
- step\_1: a Text \[text\] that says "Scale features according to their analytical meaning."
- step\_2: a Text \[text\] that says "Fit several starts and inspect stability."
- step\_3: a Text \[text\] that says "Compare credible values of k, not just one requested value."
- step\_4: a Text \[text\] that says "Inspect assignments, responsibilities, sizes, and covariance shapes."
- step\_5: a Text \[text\] that says "Validate against domain meaning and the downstream decision."
- workflow\_heading: a Heading that says "A Practical Analyst's Workflow"

#### Beats

##### [11:22.489](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666)

Narration: K-means and Gaussian mixtures answer related but different modelling questions. K-means asks for a hard partition that minimizes squared distance to centres.

Board: Empty.

Actions:
- [11:22.489](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666): comparison\_heading is shown on the screen, written out.
- [11:22.489](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.4885416666666): comparison is shown on the screen, written out.
- [11:22.559](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=682.5585416666667): comparison is shown on the screen, written out.
- [11:29.316](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=689.3155416666666): comparison (the "hard" part) is emphasized.
- [11:31.672](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=691.6715416666666): comparison (the "hard" part) is no longer emphasized.

##### [11:33.851](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=693.8510416666666)

Narration: A Gaussian mixture asks for a probability density assembled from weighted components. It returns probabilistic membership and can learn a different covariance shape for every component.

Board: comparison\_heading — a Heading that says "What Each Model Is Claiming"

Actions:
- [11:34.42](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=694.4195416666666): comparison is shown on the screen, written out.
- [11:40.98](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=700.9795416666666): comparison (the "probabilistic" part) is emphasized.
- [11:43.731](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=703.7305416666666): comparison (the "probabilistic" part) is no longer emphasized.

##### [11:46.792](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=706.7920416666666)

Narration: Choose k-means when a fast, interpretable hard partition is useful and compact groups are plausible after sensible scaling. Choose a Gaussian mixture when overlap, unequal populations, or elliptical covariance structure is part of the question.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [11:47.512](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=707.5115416666666): comparison (the "row=2" part) is emphasized.
- [11:55.987](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=715.9865416666667): comparison (the "row=2" part) is no longer emphasized.
- [11:55.987](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=715.9865416666667): comparison (the "row=3" part) is emphasized.
- [12:3.986](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=723.9860416666666): comparison (the "row=3" part) is no longer emphasized.

##### [12:4.586](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=724.5860416666666)

Narration: Neither model determines the scientifically correct number of groups by itself. K-means returns the k requested. A mixture with k components also fits the requested count, even if some fitted components become tiny or redundant.

Board: Unchanged from the preceding beat in this scene.

Actions:
- [12:20.596](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=740.5960416666666): comparison is hidden from the screen — left the board.
- [12:20.596](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=740.5960416666666): comparison\_heading is hidden from the screen — left the board.

##### [12:21.796](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=741.7960416666666)

Narration: A defensible workflow begins before fitting. Scale features according to what distance should mean, then use several starts and check whether the result is stable.

Board: Empty.

Actions:
- [12:21.796](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=741.7960416666666): workflow\_heading is shown on the screen, written out.
- [12:25.43](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=745.4295416666666): step\_1 is shown on the screen, written out.
- [12:29.552](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=749.5515416666666): step\_2 is shown on the screen, written out.

##### [12:32.718](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=752.7175416666666)

Narration: Compare several credible values of k. For k-means, inspect objective curves and resampling stability. For mixtures, likelihood criteria such as B I C can help penalize unnecessary parameters, but none of these replaces domain judgment.

Board: step\_1 — a Text \[text\] that says "Scale features according to their analytical meaning."; step\_2 — a Text \[text\] that says "Fit several starts and inspect stability."; workflow\_heading — a Heading that says "A Practical Analyst's Workflow"

Actions:
- [12:33.124](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=753.1235416666666): step\_3 is shown on the screen, written out.

##### [12:50.639](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=770.6390416666666)

Narration: Inspect the fitted objects themselves. Look for clusters created only by one scale, uncertain responsibilities, tiny components, extreme covariance estimates, and solutions that change sharply across restarts.

Board: step\_1 — a Text \[text\] that says "Scale features according to their analytical meaning."; step\_2 — a Text \[text\] that says "Fit several starts and inspect stability."; step\_3 — a Text \[text\] that says "Compare credible values of k, not just one requested value."; workflow\_heading — a Heading that says "A Practical Analyst's Workflow"

Actions:
- [12:50.988](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=770.9875416666666): step\_4 is shown on the screen, written out.

##### [13:6.1](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=786.1000416666666)

Narration: Finally, judge the clustering by the decision it supports. A useful segment, anomaly group, or population subtype must remain interpretable and stable where it will actually be used.

Board: step\_1 — a Text \[text\] that says "Scale features according to their analytical meaning."; step\_2 — a Text \[text\] that says "Fit several starts and inspect stability."; step\_3 — a Text \[text\] that says "Compare credible values of k, not just one requested value."; step\_4 — a Text \[text\] that says "Inspect assignments, responsibilities, sizes, and covariance shapes."; workflow\_heading — a Heading that says "A Practical Analyst's Workflow"

Actions:
- [13:6.658](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=786.6575416666666): step\_5 is shown on the screen, written out.

##### [13:19.309](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=799.3085416666665)

Narration: The durable lesson is simple. K-means alternates nearest-centre assignment with mean updates, and that simplicity creates both its speed and its geometric limits. Gaussian mixtures replace certainty with responsibilities and add weights and covariance, but those extra freedoms deserve validation because they can fit both real structure and noise.

Board: step\_1 — a Text \[text\] that says "Scale features according to their analytical meaning."; step\_2 — a Text \[text\] that says "Fit several starts and inspect stability."; step\_3 — a Text \[text\] that says "Compare credible values of k, not just one requested value."; step\_4 — a Text \[text\] that says "Inspect assignments, responsibilities, sizes, and covariance shapes."; step\_5 — a Text \[text\] that says "Validate against domain meaning and the downstream decision."; workflow\_heading — a Heading that says "A Practical Analyst's Workflow"

Actions:
- [13:37.769](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=817.7685416666666): step\_2 is indicated — a transient flash.
- [13:37.969](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=817.9685416666666): step\_4 is indicated — a transient flash.
- [13:38.369](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=818.3685416666666): step\_5 is indicated — a transient flash.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): step\_1 is hidden from the screen — left the board.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): step\_2 is hidden from the screen — left the board.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): step\_3 is hidden from the screen — left the board.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): step\_4 is hidden from the screen — left the board.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): step\_5 is hidden from the screen — left the board.
- [13:41.598](https://academa.ai/lectures/clustering-k-means-and-where-it-fails?t=821.598125): workflow\_heading is hidden from the screen — left the board.
