 Hello everyone, today we are going to discuss on the topic example of K-means clustering algorithm. Let us see the learning outcome of this example. At the end of this session, students will be able to explain the example of K-means clustering algorithm. Here we have four objects in the form of medicine. One medicine A, medicine B, medicine C and medicine D. We have two attributes, attribute one weight index, attribute two pH. So, attribute one weight index is 1, 2, 4, 5, attribute two pH is 1, 1, 3, 5. Now, when we define a four objects and with the two attributes, here each medicine represents one point with two attributes x, y coordinate. That we can represent it as a coordinate in an attribute space as shown in this diagram. So, here initial value of centroids. Suppose we use medicine A and medicine B as the first centroids. Let and denote the coordinate of the centroids are C1, 1, 1, C2, 2, 1 as shown in the diagram. So, in the diagram, cluster present C1, 1, 1 is in the red dot and cluster 2 is 2, 1 is again in the red dot. So, two clusters we have presented here C1, 1, 1 and C2, 2, 1. So, here we have to calculate object centroid distance. Let us calculate the distance between cluster centroid to each object. Let us use Euclidean distance, then we have distance matrix at iteration 0 because we have seen in the working of K-means algorithm, we have to follow the iteration levels. So, in the iteration 0, what will be the distance from this centroid C1, 1, 1 and C2, 2, 1. C1, 1, 1 belongs to group 1, C2, 2, 1 belongs to group 2. So, the distance calculated from this medicine objects A, B, C, D, 1, 2, 4, 5 and 1, 1, 3, 5 is. So, D0 equal to 0 for A, 1 for B, 3.61 for C, 5 for D. Similarly, in the group B, 1 for A, group 2, 1 for A, 1 for B, 3 for 2.83 and 4 for 4.24. So, this is a distance calculation to the centroids. Here each column in the distance matrix symbolizes the object. The first row of the distance matrix corresponds to the distance of each object to the first centroid and the second row is the distance of each object to the second centroid. For example, distance from medicine C, 4, 3 to the first centroid C1, 1, 1 is square root of 4 minus 1 bracket square plus 3 minus 1 bracket square is equal to 3.61. So, that is why we have written 3.61 there and its distance to the centroid, second centroid C2, 1 is 4 minus 2, 3 minus 1 square equal to 2.83. Now, we clustering those objects. When we clustering the objects, we assign each object based on the minimum distance. Thus, medicine A is assigned to group 1, medicine B to group 2, medicine C to group 3 and medicine D to group 2. The element of the group matrix below is one if and only if the object is assigned to that group. So, first group G0 forms as 1 because one group is belonging to the group A, means medicine A is assigned to the group 1. So, that is why 1 is here, so 0, 0, 0 and remaining medicine B, medicine C, medicine D is assigned to group 2, so that is why 0, B, C, D, 1, 1, 1. In the iteration 1, we determine the centroid. Knowing the members of each group, now compute the new centroid of each group based on these new membership. Group 1 only has one member, so C1 equal to 1, 1 is as it is there. Group 2 now have 3 members thus the centroid is the average coordinate among the 3 members that is C2 equal to 2 plus 4 plus 5, so how it is 2 plus 5 that is B, C and D. So, 2 plus 4 plus 5 divided by 3 and 1 plus 3 plus 4 divided by 3, so that is 11 divided by 3 and 8 divided by 3, this is our new centroid cluster 2. Now, in the next diagram iteration 1, how we calculate the centroids to the distances. This step is to compute the distance of all the objects to the new centroids which we have calculated. Now, similar to step 2, we have distance matrix at iteration 1 is, again here for ABCD are the 4 objects, so for 0 because it is cluster 1, 1 is there, so 0, then B for B that is 1 for C 3.6145 in group 1 and when we use a new centroid 11 by 3 and 8 by 3, so the second row will be 3.14, 2.36, 0.47 and 1.89. Similar to step 3, we assign each object based on the minimum distance, based on the new distance matrix, we move the medicine B to group 1 while other objects remain. The group matrix is shown in this diagram, so in the group 1 that is after iteration 1, one medicine has shifted to the group 1, so that is why that is B medicine B is shifted to the group 1, so that is why place of B we put here 1, so 1 A already is there, so 1 1 0 0 and medicine C and D shifted to the group 2, so that is why it is written 1 and 1. So second row is 0 0 1 1, which belong to group 2. Now iteration 2, in the iteration 2 we determine centroid, now we repeat step 4 to calculate the new centroid coordinate based on the clustering of previous iteration. So group 1 and group 2 both has 2 members, thus the new centroid are C 1 equal to 1 plus 2 that is 3 divided by 2, 1 plus 1 that is 2 divided by 2 is 1. So new centroid is of first C 1 is 1.5 and 1 and C 2 9 by 2 and 7 by 2. Now when we go for the iteration 2 and calculating the object centroid distance, then repeat step 2 again we have new distance matrix at iteration 2 as B distance to point A 0.5, B 0.5, 3.20 and 4.61 and second row 4.30, 5.34, 0.71 and 0.72. So this is shown in the diagram also. So after iteration 2, how we cluster the objects, again we assign each object based on the minimum distance. So that is why here when we form a group 2, the similar situation exist that is in the previous one, group 1. So in the group 1, A and B is already moved to the group 1 and C and D is already moved to the group 2, which was previous also there. So first row 1, 1, 0, 0 and second row 0, 0, 1, 1. So what is the conclusion is here? We obtain the result that G 2 equal to G 1 comparing the grouping of last iteration and this iteration reveals that the objects does not move group anymore. Thus the competition of the came in clustering has reached its stability and no more iteration is needed. So we get the final grouping as the result here. So it is shown in the diagram. So medicine A, attribute 1, 1, 2, 4, 5, medicine B, medicine C and medicine D, attribute 1, weight index 1, 2, 4, 5, pH 1134 and group that is we found the similar objects in group 1 at medicine A and medicine B and group 2, medicine C and medicine D, which is the final result of grouping decided by the original data set. Now after studying this there is a question for you. Consider the K mid in algorithm if points 0, 3, 2, 1 and minus 2, 2 are the only points which are assigned to the first cluster now. What is the new centroid of the cluster? A02, B21, C20 and 12. Answer is A02. These are the references. Thank you.