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.
Latihan ini adalah bagian dari kursus
Cluster Analysis in Python
Petunjuk latihan
- Import
fclusterandlinkagefromscipy.cluster.hierarchy. - Use the
completemethod in the.linkage()function.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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()