I opted to use xmeans to get rid of finding the best K for kmeans. So I started to use PyClustering Xmeans library. But it require to give it an initial list of centers. So how should I determine that list? I was hoping that Xmeans can calculate the right k and centers itself.
-
$\begingroup$ Welcome to Cross-Validated. Please take out the Python language particulars and translate that into questions that contain general statistical terms for our broader audience. If you do not do that, the moderators will likely remove the question as being out of scope. $\endgroup$– CarlSep 28, 2016 at 19:59
2 Answers
Because K-means is a hill-climbing algorithm, initial choice of the centers makes a big difference to performance. PyClustering implements the K++ initialization algorithm which is known to choose initial centers within a known bound of the optimal center location. The documentation for PyClustering shows how to call K++ initialization in that package.
K++ initialization (and its more scalable counterpart K||) stochastically pick initial points far from each other. They pick the initial object uniformly at random, and then select each next point with probability proportional to its distance from already chosen ones.
Choose either
- two random objects
- the two farthest objects
- a random object and it's farthest neighbor
- the first and last objects along the first eigenvector of PCA.