scikit-learn Cookbook by Hauck Trent;

scikit-learn Cookbook by Hauck Trent;

Author:Hauck, Trent;
Language: eng
Format: epub
Publisher: Packt Publishing


First, we'll look at silhouette distance. Silhouette distance is the ratio of the difference between in-cluster dissimilarity, the closest out-of-cluster dissimilarity, and the maximum of these two values. It can be thought of as a measure of how separate the clusters are.

Let's look at the distribution of distances from the points to the cluster centers; it's useful to understand silhouette distances:

>>> from sklearn import metrics >>> silhouette_samples = metrics.silhouette_samples(blobs, kmean.labels_) >>> np.column_stack((classes[:5], silhouette_samples[:5])) array([[ 1., 0.87617292], [ 1., 0.89082363], [ 1., 0.88544994], [ 1., 0.91478369], [ 1., 0.91308287]]) >>> f, ax = plt.subplots(figsize=(10, 5)) >>> ax.set_title("Hist of Silhouette Samples") >>> ax.hist(silhouette_samples)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.