Sunday, November 09, 2008
A few questions about the nstart argument for R's built-in kmeans function:
Am I correct that nstart is the number of times it randomly picks centers? So if you call kmeans with a k of 3, and an nstart value of 10, it will randomly generate 3 cluster center starting points, make cluster assignments, and then repeat that 9 more times?
Correct.
If so, how exactly does it choose which set of assignments to use? It just returns the solution that occurs most often? What if there was a tie in terms of the number of times each set of cluster assignments occurred?
It returns the solution with the smallest within-cluster MSE.
Also, should our kmeans algorithm include an nstart argument? Mine seems to be performing similarly to the one that's built in to R without one (meaning mine is only selecting random centers once).
Its a nice feature but not one that is required.
Am I correct that nstart is the number of times it randomly picks centers? So if you call kmeans with a k of 3, and an nstart value of 10, it will randomly generate 3 cluster center starting points, make cluster assignments, and then repeat that 9 more times?
Correct.
If so, how exactly does it choose which set of assignments to use? It just returns the solution that occurs most often? What if there was a tie in terms of the number of times each set of cluster assignments occurred?
It returns the solution with the smallest within-cluster MSE.
Also, should our kmeans algorithm include an nstart argument? Mine seems to be performing similarly to the one that's built in to R without one (meaning mine is only selecting random centers once).
Its a nice feature but not one that is required.