# K-Means clustering visualization & evaluation

I want to know after running Kmeans algorithm on a data set of say 10 variables and getting optimal clusters through Elbow curve - how do I to evaluate the goodness of these clusters ( i mean apart from visual review , how do i say quantitatively that these are decently spaced out clusters ? Since algorithm will anyway form clusters but whats the measure to say that these are well formed distinct clusters or 'natural groups' like a comparison to standard measure of distance ?

And whats the best way to visualize Kmeans done on multidimensional data ? Is it something like TSNE or first doing PCA and then visualizing ?

• KNN is used for classification, K-Means is used for clustering. Which one are your referring to? – Arun Jose Apr 4 '17 at 6:36
• My apologies , I mean K-means . – Pb89 Apr 4 '17 at 6:37
• A simple google search would have revealed similar questions on stackoverflow: stats.stackexchange.com/questions/30578/… – Arun Jose Apr 4 '17 at 7:02
• Possible duplicate of Quantitative evaluation metric of kmeans clustering results – Arun Jose Apr 4 '17 at 7:02
• @Arun Jose- I did have a look at that , but as per my understanding those methods need class labels for evaluation. Perhaps my understanding is incorrect. I'll read more on it . I was looking more from a standard eval metric like when we say p value less <0.05 then its statistically significant , is there something similar to evaluate 'quality of clusters based on how well spaced or differentiated they are' apart from how much variance they explain . – Pb89 Apr 4 '17 at 8:31

I recently looked for the best method for clustering comparison and I can safely state that the best one (for independence from the number of clusters and selecting bias in random tests) is the so-called adjusted random index. Other techniques have bloomed around but reading about it seems not necessary because this measure has all the 'good qualities'. A standard article to read about is: Vinh, N. X., Epps, J. & Bailey, J. Information Theoretic Measures for Clusterings Comparison: Variants, Properties, Normalization and Correction for Chance. J. Mach. Learn. Res. 11, 2837–2854 (2010)..

I do not agree with the first answer as the clusteval package has only the simple rand index which is not adjusted for random bias (i.e. tends to be good for large number of clusters really easily - see article). As there are many packages having the ARI measure I tested the efficiencies and the best is hands down the C implementation in phyclust with the RRand() function (phyclust::RRand). It takes microseconds for 150 labeled numbers with 50 clusters.

For the t-sne vs pca go for t-sne. It is like MIC for correlation. Just better. Obviously, it can be cumbersome to calculate for big data-set so pay attention. It is implemented in Rtsne. Check this tutorial out about the two methods compared.

• I advise you also to check this wonderful post on t-SNE parameters. – Garini May 31 '18 at 8:58

You can look up Silhouette widths. These are indices of cluster validity, and can help you identify which data points have a poor fit, or which clusters are less cohesive. They also give out a silhouette plot, which is basically the silhouette widths for all data points.

There are several different indices available for cluster validity. If you are conversant with R, lookup the package cluster, cluseval (not sure of the capitalization here).

You can visualize using PCA. You can plot what is called a Biplot (BiplotGUI in R) or a MDS plot, and assign say different colours to data points belonging to different clusters to get a rough visualization of the cluster. But these are not very robust methods, since a lot of information is lost in dimensionality reduction.