silhouette coefficient silhouette coefficient is metric that tries to combine the two requirements of good clustering model the silhouette coefficient is defined for each sample and is combination of its similarity to the data points in its own cluster and its dissimilarity to the data points not in its cluster the mathematical formula of silhouette coefficient for clustering model with data points is given by sample sci = heresample sc is the silhouette coefficient for each of the samples the formula for sample' silhouette coefficient issample sc - max , herea mean distance between sample and all other points in the same class mean distance between sample and all other points in the next nearest cluster the silhouette coefficient is usually bounded between - (incorrect clusteringand + (excellent quality dense clustersa higher value of silhouette coefficient generally means that the clustering model is leading to clusters that are dense and well separated and distinguishable from each other lower scores indicate overlapping clusters in scikit-learnwe can compute the silhouette coefficient by using the silhouette_ score function the function also allows for different options for distance metrics from sklearn import metrics km _silc metrics silhouette_score(xkm _labelsmetric='euclidean'km _silc metrics silhouette_score(xkm _labelsmetric='euclidean'print('silhouette coefficient for num clusters= 'km _silcprint('silhouette coefficient for num clusters= 'km _silcsilhouette coefficient for num clusters= silhouette coefficient for num clusters= based on the preceding outputwe can observe that from the metric results it seems like we have better cluster quality with two clusters as compared to five clusters calinski-harabaz index the calinski-harabaz index is another metric that we can use to evaluate clustering models when the ground truth is not known the calinski-harabaz score is given as the ratio of the between-clusters dispersion mean and the within-cluster dispersion the mathematical formula for the score for clusters is given bys ( tr bk tr (wk -