Example on K- means

Duration: 8 min

This video lesson is available to enrolled students.

Enroll to watch — ZERO TO HERO

AI Summary

An AI-generated summary of this video lecture.

The video provides a step-by-step example of the K-Means clustering algorithm applied to eight 2D data points, aiming to partition them into three clusters and compute new cluster centers after two iterations. The process begins with defining the dataset: eight points labeled A1 through A8, each with (x, y) coordinates. The initial cluster centers are specified as A1(2,10), A4(5,8), and A7(1,2). The Manhattan distance function is used for all calculations: P(a,b) = |x₂ - x₁| + |y₂ - y₁|. The algorithm proceeds in iterations, starting with Iteration 01, where the distance from each point to every cluster center is computed. For instance, A1(2,10) has a distance of 0 to C1(2,10), 5 to C2(5,8), and 9 to C3(1,2), so it is assigned to Cluster 1. This assignment process continues for all points, resulting in the first cluster assignments: Cluster 1 contains A1; Cluster 2 includes A3, A4, A5, A6, and A8; Cluster 3 contains A2 and A7. After the first iteration, new cluster centers are recalculated by averaging the coordinates of points in each cluster. For example, Cluster 1’s new center is (2,10) since only A1 belongs to it. Cluster 2’s new center is calculated as the average of (8,4), (5,8), (7,5), (6,4), and (9,9), resulting in approximately (6.8, 6). Cluster 3’s new center is the average of A2(2,5) and A7(1,2), yielding (1.5, 3.5). The second iteration begins by recalculating distances from each point to the updated centers, reassigning points based on minimum distance. The video shows that A4(5,8) is reassigned to Cluster 2 due to its proximity. The final cluster centers after the second iteration are updated based on these new assignments, with Cluster 1 center at (3,9.5), Cluster 2 at (6.5,5.25), and Cluster 3 at (1.5,3.5). The video emphasizes the iterative nature of K-Means: assign points to nearest center, then update centers via averaging. The visual content includes on-screen text listing the data points, initial centers, distance formula, and tables showing cluster assignments at each stage. The teaching flow is structured to guide students through the mechanics of distance computation, point assignment, and center recalculation in a clear, sequential manner.

Chapters

  1. 0:00 2:00 00:00-02:00

    The video introduces an example problem for the K-Means clustering algorithm, presenting eight 2D points and three initial cluster centers. It specifies the use of Manhattan distance: P(a,b) = |x₂ - x₁| + |y₂ - y₁|. The goal is to find the new cluster centers after two iterations. On-screen text lists the points: A1(2,10), A2(2,5), A3(8,4), A4(5,8), A5(7,5), A6(6,4), A7(1,2), A8(9,9). Initial centers are given as A1(2,10), A4(5,8), and A7(1,2). The solution begins with Iteration 01, where distances from each point to the three centers are calculated. The instructor frames this as a step-by-step example, emphasizing that the first task is to compute distances and assign points to their nearest cluster based on the defined metric.

  2. 2:00 5:00 02:00-05:00

    The video demonstrates the first iteration of K-Means by calculating Manhattan distances from each point to the three initial cluster centers. For example, A1(2,10) has a distance of 0 to C1(2,10), 5 to C2(5,8), and 9 to C3(1,2), so it is assigned to Cluster 1. The process is shown for multiple points, with on-screen text displaying the distance calculations and assignments. A table appears showing that Cluster 1 contains only A1, Cluster 2 includes A3(8,4), A4(5,8), A5(7,5), A6(6,4), and A8(9,9), while Cluster 3 contains A2(2,5) and A7(1,2). The instructor emphasizes that points are assigned to the nearest center based on minimum distance. After assignment, new cluster centers are computed by averaging the coordinates of points in each cluster: Cluster 1 remains (2,10), Cluster 2 becomes approximately (6.8, 6), and Cluster 3 becomes (1.5, 3.5). The video transitions to the second iteration with a clear explanation of the next steps.

  3. 5:00 8:01 05:00-08:01

    The video presents the second iteration of K-Means, where distances are recalculated using the updated cluster centers: C1(2,10), C2(6.8,6), and C3(1.5,3.5). For example, A4(5,8) is reassigned to Cluster 2 because its distance to C2 (|5-6.8| + |8-6| = 1.8 + 2 = 3.8) is less than to C1 (|5-2| + |8-10| = 3 + 2 = 5). The updated cluster assignments are shown in a table: Cluster 1 has A1(2,10), Cluster 2 includes A3(8,4), A4(5,8), A5(7,5), A6(6,4), and A8(9,9), while Cluster 3 has A2(2,5) and A7(1,2). New cluster centers are recalculated: Cluster 1 center is (2,10), but after reassignment, it becomes the average of A1(2,10) and possibly others. The final centers are displayed as (3,9.5), (6.5,5.25), and (1.5,3.5). The video concludes by showing the updated cluster assignments and centers after two iterations, reinforcing that K-Means converges through repeated assignment and center update steps.

The video systematically demonstrates the K-Means clustering algorithm using a concrete example with eight 2D points and three initial cluster centers. It emphasizes the use of Manhattan distance for measuring proximity, a choice that simplifies computation and avoids Euclidean square roots. The core teaching progression follows the algorithm’s two-phase loop: (1) assignment, where each point is assigned to the nearest cluster center based on minimum distance; and (2) update, where each cluster’s new center is computed as the mean of all points assigned to it. The example illustrates how initial centers influence cluster formation and how reassignment can occur in subsequent iterations, leading to convergence. The visual structure supports learning by showing step-by-step calculations and tabular summaries of assignments, reinforcing the iterative refinement process. The video is designed for educational purposes, guiding students through a complete cycle of K-Means to understand both the mechanics and logic behind unsupervised clustering.