I have salary data of several user (Python list).Now I am using KMeans to cluster them.Given this data, Is there a way to figure out the best value for 'K' automatically through program?I tried silhouette analysis:http://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.htmltake k with highest silhouette_avg score. Is this the best way?
Determinate K in K-Means Clustering
python;clustering;k means
Wang, Kaijun, Baijie Wang, and Liuqing Peng. CVAP: Validation for cluster analyses. Data Science Journal 0 (2009): 0904220071.:To measure the quality of clustering results, there are two kinds of  validity indices: external indices and internal indices. An external  index is a measure of agreement between two partitions where the first  partition is the a priori known clustering structure, and the second  results from the clustering procedure (Dudoit et al., 2002). Internal  indices are used to measure the goodness of a clustering structure  without external information (Tseng et al., 2005).For external indices, we evaluate the results of a clustering algorithm based on a known cluster structure of a data set (or cluster labels).For internal indices, we evaluate the results using quantities and features inherent in the data set. The optimal number of clusters is usually determined based on an internal validity index.(Dudoit et al., 2002): Dudoit, S. & Fridlyand, J. (2002) A prediction-based resampling method for estimating the number of clusters in a dataset. Genome Biology, 3(7): 0036.1-21.(Tseng et al., 2005): Thalamuthu, A, Mukhopadhyay, I, Zheng, X, & Tseng, G. C. (2006) Evaluation and comparison of gene clustering methods in microarray analysis. Bioinformatics, 22(19):2405-12.In your case, you need some internal indices since you have no a priori clustering structure. There exist tens of internal indices, like:Silhouette index (implementation in MATLAB)Davies-BouldinCalinski-HarabaszDunn index (implementation in MATLAB)R-squared indexHubert-Levin (C-index)Krzanowski-Lai indexHartigan indexRoot-mean-square standard deviation (RMSSTD) indexSemi-partial R-squared (SPR) indexDistance between two clusters (CD) indexweighted inter-intra indexHomogeneity indexSeparation indexEach of them have pros and cons, but at least they'll give you a more formal basis for your comparison. The MATLAB toolbox CVAP might be handy as it contains many internal validity indices.More information:Determining the number of clusters in a data setHow to determine which method is the most reasonable clustering results?How can I detect if my dataset is clustered or unclustered (i.e. forming one single cluster)?How can we choose a good K for K-means clustering?Cluster analysis in R: determine the optimal number of clusters