title: AgglomerativeClustering, no attribute called distances_
body: <p>So I tried to learn about hierarchical clustering, but I alwas get an error code on spyder:</p>
  
  <pre><code>AttributeError: 'AgglomerativeClustering' object has no attribute 'distances_'
  </code></pre>
  
  <p>This is the code</p>
  
  <pre><code>from sklearn.cluster import AgglomerativeClustering
      import pandas as pd
  
      df = pd.DataFrame({
              'x':[41, 36, 32, 34, 32, 31, 24, 30, 45, 52, 51, 52, 55, 53, 55, 61, 64, 69, 72],
              'y':[39, 36, 30, 52, 54, 46, 55, 59, 63, 70, 66, 63, 58, 23, 30, 30, 31, 32, 29]
              })
      clustering = AgglomerativeClustering(n_clusters=None, distance_threshold=0)
      clustering.fit(df)
  
      import numpy as np
      from matplotlib import pyplot as plt
      from scipy.cluster.hierarchy import dendrogram
  
      def plot_dendrogram(model, **kwargs):
          # Create linkage matrix and then plot the dendrogram
          # create the counts of samples under each node
          counts = np.zeros(model.children_.shape[0])
          n_samples = len(model.labels_)
          for i, merge in enumerate(model.children_):
              current_count = 0
              for child_idx in merge:
                  if child_idx &lt; n_samples:
                      current_count += 1  # leaf node
                  else:
                      current_count += counts[child_idx - n_samples]
              counts[i] = current_count
  
          linkage_matrix = np.column_stack([model.children_, model.distances_,
                                            counts]).astype(float)
  
          # Plot the corresponding dendrogram
          dendrogram(linkage_matrix, **kwargs)
  
  
  
      plt.title('Hierarchical Clustering Dendogram')
             #plot the top 3 levels of the dendrogram
      plot_dendrogram(clustering)
      plt.xlabel("index data")
      plt.show()
      #print(clustering.labels_)
  </code></pre>
  
  <p>I have upgraded the scikit learning to the newest one, but the same error still exist, so is there anything that I can do? or is there something wrong in this code</p>