sklearn.metrics.silhouette_samples(X, labels, metric=’euclidean’, **kwds)
[source]
Compute the Silhouette Coefficient for each sample.
The Silhouette Coefficient is a measure of how well samples are clustered with samples that are similar to themselves. Clustering models with a high Silhouette Coefficient are said to be dense, where samples in the same cluster are similar to each other, and well separated, where samples in different clusters are not very similar to each other.
The Silhouette Coefficient is calculated using the mean intracluster distance (a
) and the mean nearestcluster distance (b
) for each sample. The Silhouette Coefficient for a sample is (b  a) / max(a,
b)
. Note that Silhouette Coefficient is only defined if number of labels is 2 <= n_labels <= n_samples  1.
This function returns the Silhouette Coefficient for each sample.
The best value is 1 and the worst value is 1. Values near 0 indicate overlapping clusters.
Read more in the User Guide.
Parameters: 


Returns: 

[1]  Peter J. Rousseeuw (1987). “Silhouettes: a Graphical Aid to the Interpretation and Validation of Cluster Analysis”. Computational and Applied Mathematics 20: 5365. 
[2]  Wikipedia entry on the Silhouette Coefficient 
sklearn.metrics.silhouette_samples
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.metrics.silhouette_samples.html