How is the average of points calculated?


#1

Question

In the context of this exercise, describing step 3 of K-Means clustering, how is the average of points calculated?

Answer

In this exercise, we utilize the np.mean() function to calculate the average of data points.

What this will do is average each dimension (x, y, z, …) of the points individually, and then those averages will determine the average of those points.

For example, say that we had the 2-dimensional points

[[0, 3],
 [2, 5],
 [4, 7]]

The average of these points would then be obtained by averaging each dimension individually,

x = (0 + 2 + 4) / 3 = 2
y = (3 + 5 + 7) / 3 = 5

The average of the points will then be [2, 5].