Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to do cluster analysis in kmodes?

Now I am doing food clustering using the feature of their ingredient and since it is categorical data so I use kmodes. Here are the source code

     import pandas as pd

     # Load the Drive helper and mount
     from google.colab import drive

     # This will prompt for authorization.
     drive.mount('/content/drive')

     # After executing the cell above, Drive
     # files will be present in "/content/drive/My Drive".
     !ls "/content/drive/My Drive"

     data=pd.read_csv('dataset.csv')

     !pip install kmodes

     from kmodes.kmodes import KModes
     km = KModes(n_clusters=10, init='Cao', n_init=5, verbose=1)
     clusters = km.fit_predict(data)
     print(km.cluster_centroids_)

Yes I got the centroid, but I want to know/analyze whether it is goo hence I want to calculate silhouette score and purity score and plotting both of them and since tutorial I found out on google is only about kmeans, I have no idea how to do it in the sense of kmodes python. Thank you.

Comments