# How to choose k-means clustering variables?

I want to use k-means clustering algorithm to cluster my data into two clusters, tight as possible. I have the following questions:

1. Are there any roles to choose the variables needed to cluster the data. e.g I have 100 patients who diagnosed of having a disease. I have the rate of disease progression and the disease duration since diagnosis.

The formula that calculate the rate of disease progression depends on a clinical scale for disease evaluation, and disease duration as follow :

rate of disease progression= (total clinical scale - current clinical scale) / disease duration


I aim to divide the patients into two groups (slow disease progression and fast disease progression) by feeding the rate of disease progression and disease duration as variables into k-means. Is this choice, for the variables, correct?.

In other words the rate of disease progression was calculated depending in part on disease duration. Can this affect clustering the data using two variables one derived from the other one? Or I need,just, any two or more variables that can make dividing the patients make sense?

1. When clustering the data, using k-means, I need to choose the clusters tight as possible ( i.e. the data points are close as possible to the centroid of each cluster). Is it advisable to remove the outiers from the clusters. For example:

In the figure bellow, there are three clusters. the data points are concentrated in almost 90% around the centroids ( within each cluster). Do I need to remove the data points that are so far away from the centroid of the clusters ( #1 and #3).

• Have you considered using the DBSCAN (en.wikipedia.org/wiki/DBSCAN) clustering algorithm? In the DBSCAN algorithm, you can specify a minimum number of points and a minimum radius so that you need not arbitrarily exclude outliers, but you can group observations as long as they are sufficiently close to one another. If you're required to use or strongly prefer using k-means, disregard this - but this method might be more appropriate for what it seems like you want to do. – Matt Brems Jul 27 '16 at 19:58
• @MattBrems. Thank you very much for bringing this out!! Actually, I am not familiar at all with DBSCAN. I will study it, and I will try to apply it in my future analyses. I used to cluster my data using k-means, and I have concerns regarding choosing the variables, as well as the outliers. and these are the reason behind my questions ! – goro Jul 27 '16 at 20:05
• There are no clusters in that figure. K-means is a bad choice, becausenit always produces something, even when it's really bad. Clearly, you data was not preprocessed well enough. There is a nonlinear effect that ruined PCA. So 1) improve preprocessing, 2) find a projection where you can see (literally) clusters. Only then run a clustering algorithm, and compare it to your visual interpretation! – Has QUIT--Anony-Mousse Aug 21 '16 at 15:13
• @Anony-Mousse. Than you for your comment! Kindly could you please add your comments as a detailed response. I was unable to understand what you mean by "improve preprocessing" or "find a projection where you can see (literally) ". This is a clinical data !!! Looking forward to learn from you ! – goro Aug 21 '16 at 20:23
• I don't have your data. I don't know what preprocessing is right for you - every data set is different! But in your biplot above, there are not clusters; but a nonlinear correlation that is problematic as it will ruin your clustering results. – Has QUIT--Anony-Mousse Aug 21 '16 at 20:32