I have found this implementation of K-Medoids and I decided to try it in my code.
My original dataset is a 21x6 matrix.
To generate the distance matrix I'm using:
import scipy.spatial.distance as ssd
distanceMatrix = ssd.squareform(ssd.pdist(matr, 'cosine'))
Then I decide a number of clusters:
clusters = int(np.sqrt(len(matr.data)/2))
And finally:
clusters, medoids = self.cluster(distanceMatrix,clusters)
print(clusters)
print(medoids)
For the given input, I get this output:
[12 12 12 12 12 12 12 7 7 7 7 11 12 12 12 12 12 12 11 12 12]
[12 7 11]
While I was expecting an output similar to sklearn.cluster.KMeans where I have a label for each point in my matrix.
How should I treat this kind of output if I want to use the result to scatter cluster elements, like in the picture below (where I used k-Means)?