I am working on clustering and I have 90 features with 13500 data points and after removing the correlated variables which had pearson correlation more than 90% my feature space reduced to 70. Also, almost all my original 90 features has lot of values as zeros (more than 70-80% of data points). What I did in terms of algorithmic implementation is :

  1. Ran K-Means on original data with 70 features (all numerical) by selecting number of clusters based on Silhouette index.
  2. Ran K-Means by reducing the dimensions to 2 by selecting the number of clusters based on silhouette index.

What I observed and my corresponding question is :

  1. K-Means on pca reduced data gave better clusters. Is there any way I can use this clusters that would make sense ? Like assigning the cluster labels from pca reduced data to the original data
  2. How is the K-Means on original data and K-Means on pca reduced data different ? I understand that the pca would have reduced the data to two dims that I chose and has preserved the components with max variance. But can I assign the cluster labels from the pca reduced data to the original data ? would it be a right approach ? I guess not.

Also, there are many implementation of K-Means like Lloyds (Python), Elkan(Python), Hartigan-Wong(R), Forgy(R), MacQueen(R). Which of these can be used for numerical vars and which one for categorical ? I think, wong is used for categorical variables not sure though. Also, which of these Implementations can I simply rule out ?


1 Answer 1


But can I assign the cluster labels from the pca reduced data to the original data ? would it be a right approach ? I guess not.

Yes, that is totally the right approach. Principal components are just the linear combinations of your original features that explain the most variance, so you can definitely use them for clustering. Moreover, since you only kept 2 of them you also removed a lot of noise from your data - since K-means is based on distances, the fact of having 70 features can be problematic, as you're equally weighting distances on useless features and distances on important ones.

Summing up - yes, assign the cluster based on the results of Kmeans you obtained on the Principal Components.

Unfortunately I cannot help you with the implementations, but remember then when mixing categorical and continuous variables you need to define an appropriate distance metric between your points. And any good implementation should allow you to do so for categorical only or continuous only data. Not sure about the mix.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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