I have a very basic question on clustering. After I have found k clusters with their centroids, how do I go about interpreting the classes of the data points that I have clustered (assigning meaningful class labels to each cluster). I am not talking about validation of the clusters found.

Can it be done given a small labelled set of data points, compute to which cluster these labelled points belong to and based on type and number of points each cluster receives, decide the label? This seems pretty obvious but I don't know how standard it is to assigns labels to clusters this way.

To be clear, I want to perform unsupervised clustering that doesn't use any labels to first find my clusters. Then having found the clusters, I want to assign meaningful class labels to the clusters based on the properties of a few example datapoints.

  • $\begingroup$ I'm not sure to understand your question: usually, any k-means algorithm should return information on class membership for each data point. Are you talking about actual data points or new observations? $\endgroup$ – chl Mar 5 '13 at 22:19
  • $\begingroup$ @chi I suspect Riyaz is concerned about finding names with which to label the clusters and is talking about a priori naming some of the points and then using some algorithm which considers the preponderance of named points in the clusters to then name those clusters. $\endgroup$ – Glen_b -Reinstate Monica Mar 5 '13 at 22:34
  • 2
    $\begingroup$ @Riyaz, could we use the following analogy to Factor Analysis to understand your question? Often someone will factor analyze a set of variables to cluster them into groups of variables that seem to 'hang together', but then the analyst needs to think about the nature of the variables that make up each cluster to come up w/ a name for / way of thinking about what each cluster (factor) is. Is that essentially what you're getting at here? $\endgroup$ – gung - Reinstate Monica Mar 5 '13 at 23:19

Yes. What you propose is entirely standard and it is the way that standard k-means software works automatically. In the case of k-means you compute the euclidean distance between each observation (data point) and each cluster mean (centroid) and assign the observations to the most similar cluster. Then, the label of the cluster is determined by examining that average characteristics of the observations classified to the cluster relative to the averages of those relative to the other clusters.


If you look at the names in your kmeans object you will notice that there is a "cluster" object. This contains the class labels ordered the same as your input data. Here is a simple example that binds the cluster labels back to your data.

x <- data.frame(X=rnorm(100, sd=0.3), Y=rnorm(100, mean=1, sd=0.3))

k <- kmeans(x, 2) 
x <- data.frame(x, K=k$cluster)

# You can also directly return the clusters
x <- data.frame(x, K=kmeans(x, 2)$cluster)

The labels to the cluster may be based on the class of majority samples within a cluster. But this is true only if the number of clusters is equal to number of classes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.