I noticed a bug when using init == "random" for KMedoids. You'll at times not get the requested number of clusters. The issue is that the initial medoids are being randomly sampled with replacement. This sets the flag to not sample with replacement.
I've also added a test to ensure n_clusters is correct for all initializations / method combinations.
Here's a repro if you're curious:
kmedoids = sk.cluster.KMedoids(10, init="random", random_state=123)
kmedoids.fit(np.array([(x, x) for x in range(15)]))
assert len(np.unique(out.medoid_indices_)) == 10
I noticed a bug when using
init == "random"
forKMedoids
. You'll at times not get the requested number of clusters. The issue is that the initial medoids are being randomly sampled with replacement. This sets the flag to not sample with replacement.I've also added a test to ensure
n_clusters
is correct for all initializations / method combinations.Here's a repro if you're curious: