I am looking for a proper method to choose the number of clusters for K modes. 

I tried to find the optimal number of clusters by maximizing the average silhouette width though. 

In k-modes,  the average silhouette width increases with the increase of the number of clusters with my case.

So i tried to derive the elbow plot and I got the attached graph.

It is quite hard to which point is the location of a bend in this plot.. 

In this case, how can I choose the best number of groups? 

and Can anyone introduce better method that help choose the optimal number of clusters for K-modes? 

  • $\begingroup$ the graph is attached as above. :) $\endgroup$ Commented Dec 14, 2016 at 2:21
  • $\begingroup$ Hi @user3242742, what is the total within diff in your plot? $\endgroup$
    – dmeu
    Commented Sep 8, 2017 at 13:19
  • $\begingroup$ im facing the same problem. did you get the solution? $\endgroup$
    – anna
    Commented Oct 17, 2017 at 9:25
  • $\begingroup$ How did you determine the total within difference? $\endgroup$
    – RNB
    Commented Oct 14, 2019 at 12:36

1 Answer 1


The elbow is at 4.

Afterwards, the drop follows the usual behavior of random data and 1/x curves.

Since the elbow is not very prominent, the results likely are not very good, and you need to evaluate other preprocessing and clustering methods if they work better.

  • $\begingroup$ Thanks for comment. :) Now I see. I tried to use NbClust packages in R though, it does not provide "K-modes" method... Would you recommend other clustering method for categorical variables? $\endgroup$ Commented Dec 14, 2016 at 2:24
  • $\begingroup$ Categorical variables often don't cluster well. I'd consider frequent itemset mining. $\endgroup$ Commented Dec 14, 2016 at 7:15
  • 1
    $\begingroup$ Actually, R does provide k-modes in the klaR package. $\endgroup$
    – G5W
    Commented Dec 14, 2016 at 16:46
  • 1
    $\begingroup$ @G5W yes I tried this with the klaR package though, it does not provide the additional method to support the decision to choose the proper number of clusters. $\endgroup$ Commented Dec 15, 2016 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.