title: Finding the optimal number of clusters from Dendrogram
body: <p>I am using a dendrogram to visualise the number of clusters formed by a dataset of phrases. I'm using -</p>
  <pre><code>from scipy.cluster.hierarchy import dendrogram, linkage
  Z = linkage(X.todense(), 'ward')
  dn = hierarchy.dendrogram(Z)
  plt.axhline(y=2, color='r', linestyle='--')
  plt.title('Dendrogram')
  plt.ylabel('Distance')
  plt.show()
  </code></pre>
  <p>How can I count the number of clusters being formed at a particular 'y' from the dendrogram? For eg. I'd like to find out and compare the number of clusters at <code>y=2</code> and <code>y=1.5</code>.</p>
  <p>Also, is there a relationship between the y (distance between clusters) and the optimal number of clusters, as in the case of K-Means Clustering (something analogous to Elbow Method, Silhouette Method)?</p>