Hierarchical clustering: complete method
For the third and final time, let us use the same footfall dataset and check if any changes are seen if we use a different method for clustering.
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.
This exercise is part of the course
Cluster Analysis in Python
Exercise instructions
- Import
fclusterandlinkagefromscipy.cluster.hierarchy. - Use the
completemethod in the.linkage()function.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the fcluster and linkage functions
____
# Use the linkage() function
distance_matrix = ____(____, ____, ____)
# Assign cluster labels
comic_con['cluster_labels'] = ____
# Plot clusters
sns.scatterplot(x='x_scaled', y='y_scaled',
hue='cluster_labels', data = comic_con)
plt.show()