IniziaInizia gratis

Create a dendrogram

Dendrograms are branching diagrams that show the merging of clusters as we move through the distance matrix. Let us use the Comic Con footfall data to create a dendrogram.

The data is stored in a pandas DataFrame, comic_con. x_scaled and y_scaled are the column names of the standardized X and Y coordinates of people at a given point in time. cluster_labels has the cluster labels. A linkage object is stored in the variable distance_matrix.

Questo esercizio fa parte del corso

Cluster Analysis in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Import the dendrogram function from scipy.cluster.hierarchy.
  • Create a dendrogram using the linkage object.
  • Display the dendrogram using .show() method of the plt object.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Import the dendrogram function
____

# Create a dendrogram
dn = ____(____)

# Display the dendogram
____.____()
Modifica ed esegui il codice