5

I am using FindClusters with the Method -> "KMedoids" option. I am specifying a desired number of clusters. It returns with many fewer than the desired number. Is there a way to force it to return the desired number? For reference a code snippet is

    nclusters = 1207;
    Length /@ {vectors, weights}
    weighteddata = WeightedData[vectors, weights];
    clusters = FindClusters[weighteddata, nclusters, Method -> "KMedoids"];
    Length[clusters];

output is

{58852, 58852}

453

All of the elements in vectors are distinct, so it is unclear why it finds only 453 clusters. The documentation says it will partition into "at most" nclusters, but does not say whether or how one can force a specific number of clusters.

Any help would be appreciated.

In response to a request, here is a worked example.

n = 10000;
k = 1000;
vectors = RandomReal[{-1, 1}, {n, 3}];
weights = RandomInteger[{1, 1000}, n];
clusters = 
  FindClusters[WeightedData[vectors, weights], k, 
   Method -> "KMedoids"];
Length[clusters]

output is

427
abwatson
  • 1,919
  • 1
  • 12
  • 19

0 Answers0