<< Chapter < Page | Chapter >> Page > |
In the clustering problem, we are given a training set , and want to group the data into a few cohesive “clusters.”Here, as usual; but no labels are given. So, this is an unsupervised learning problem.
The -means clustering algorithm is as follows:
In the algorithm above, (a parameter of the algorithm) is the number of clusters we want to find; and the cluster centroids represent our current guesses for the positions of the centers of the clusters. To initialize thecluster centroids (in step 1 of the algorithm above), we could choose training examples randomly, and set the cluster centroids to be equal to the values ofthese examples. (Other initialization methods are also possible.)
The inner-loop of the algorithm repeatedly carries out two steps: (i) “Assigning” each training example to the closest cluster centroid , and (ii) Moving each cluster centroid to the mean of the points assigned to it. [link] shows an illustration of running -means.
Is the -means algorithm guaranteed to converge? Yes it is, in a certain sense. In particular, let us define the distortion function to be:
Thus, measures the sum of squared distances between each training example and the cluster centroid to which it has been assigned. It can be shown that -means is exactly coordinate descent on . Specifically, the inner-loop of -means repeatedly minimizes with respect to while holding fixed, and then minimizes with respect to while holding fixed. Thus, must monotonically decrease, and the value of must converge. (Usually, this implies that and will converge too. In theory, it is possible for -means to oscillate between a few different clusterings—i.e., a few different values for and/or —that have exactly the same value of , but this almost never happens in practice.)
The distortion function is a non-convex function, and so coordinate descent on is not guaranteed to converge to the global minimum. In other words, -means can be susceptible to local optima. Very often -means will work fine and come up with very good clusterings despite this. But if you are worried about getting stuck in badlocal minima, one common thing to do is run -means many times (using different random initial values for the cluster centroids ). Then, out of all the different clusterings found, pick the one that gives the lowest distortion .
Notification Switch
Would you like to follow the 'Machine learning' conversation and receive update notifications?