I have used and taught K-means cluster for many years. I have never worried too much about sort order, but a recent experience made me revisit it. I was running a simple data set through all the IBM SPSS Statistics (SPSS) Cluster Techniques, and also ran them all through IBM SPSS Modeler (Modeler). The short version of the story is that the results were not identical.
Consider the following SPSS output with the default 10 iterations:
The "Iteration History" (not shown) would indicate that the solution had not converged. It may not be immediately clear what you are seeing here because the clusters are moved around. Upon scrutiny, however, you will find that some of the values simply do not match. Clearly sorting (in this case on ID) changes the results. It is not desirable to have unstable results.
There are three interesting options.
1) Consider using Hierarchical first, calculation the cluster centers, and then sending those as the initial cluster centers. I have always been frustrated that Help does not make it clear how to format this information in the required file. While this is still true, the Syntax Reference Guide does make it clear. (Note: Modeler does not support Hierarchical because it is VERY slow on large data sets.)
2) Consider reading up on K++. While not implemented in SPSS or Modeler, there is some interesting information on this new (2007) algorithm. One could always consider R or Python for implementation.
For a Python implementation consider the following page I found. I wish I could say I have tried to combine this with syntax to produce a complete solution – I have not.
3) The third option, and definitely the easiest, is to simply increase the number of iterations. See the results using 20 iterations. Notice that all the values are identical.


