0

I am trying to form clusters around medoids using PAM algorithm in R. Is there anyway of fixing the cluster size for PAM (somewhat bruteforce the cluster size) ? Are there any other clustering algorithms that will provide equal sized clusters for medoids ?

Thank you in advance for your help.

Lawrence
  • 427
  • 5
  • 15
  • Duplicate to: http://stats.stackexchange.com/questions/8744/clustering-procedure-where-each-cluster-has-an-equal-number-of-points – Has QUIT--Anony-Mousse Jun 03 '16 at 17:49
  • Special case of duplicate: [Optimal grouping/clustering of items in groups with minimum size](http://stackoverflow.com/questions/37589168/optimal-grouping-clustering-of-items-in-groups-with-minimum-size) – Has QUIT--Anony-Mousse Jun 03 '16 at 21:40
  • Hi @Lawrence did you get any answer to this problem? I'm looking for an R implementation of such algorithm, but couldn't find any. thanks – agenis Sep 26 '17 at 16:30

1 Answers1

2

You can modify a clustering algorithm to suit your needs.

You can follow this Tutorial for Same-Size K-Means, or simply use this algorithm from the tutorial package/module in ELKI (build the latest version from GitHub, because I just fixed a bug there - this will be included in ELKI 0.7.2).

Essentially, this algorithm performs a k-means style least-squares optimization, but all clusters must have the same size (if N/k is not integer, the cluster sizes may vary by 1).

If you go to above tutorial and scroll to the bottom, you can see example results.

Erich Schubert
  • 8,575
  • 2
  • 26
  • 42
  • Thank you for your answer. Unfortunately I am working with a dissimilarity matrix (I do not have coordinates to be able to use kmeans). My data is in the form objects and a weight is attributes to each pair. That's why I am using PAM. I have however developed my own clustering algorithm appropriate to my problem. Will post it when I finish coding. Thanks again ! – Lawrence Jun 09 '16 at 09:34
  • You can essentially follow the tutorial, but work with KMedoidsEM instead of KMeans. It's similar to k-means but uses the medoid like PAM. With above modifications, you will get a k-medoids that ensures clusters have the same size. – Erich Schubert Jun 09 '16 at 13:52