Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I came across a variant of k-means that adds a algorithm to select good starting values called k-means++.

kMeansInitializer[data_, k_Integer] :=
 Module[
  {startingPoint = RandomChoice[data], getDistance, getDistances, 
   nextPoint},
  getDistance[datum_, points_] := Min[Norm[datum - #]^2 & /@ points];
  getDistances[points_] := getDistance[#, points] & /@ data;
  nextPoint[points_] := RandomChoice[getDistances[points] -> data];
  NestList[nextPoint, startingPoint, k - 1]
  ]

After implementing the algorithm (a bit of a challenge for someone at my level) I now find I have no idea how to feed the values I generate to ClusteringComponents to use as initial values for use in its k-means implementation.

share|improve this question
I don't think it is possible to do that via ClusteringComponents. Here's an implementation of k-means that I wrote, which might be easily extended to your needs. – rm -rf Oct 3 '12 at 23:33

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.