Different linkage, different hierarchical clustering!
In the video, you saw a hierarchical clustering of the voting countries at the Eurovision song contest using 'complete' linkage. Now, perform a hierarchical clustering of the voting countries with 'single' linkage, and compare the resulting dendrogram with the one in the video. Different linkage, different hierarchical clustering!
You are given an array samples. Each row corresponds to a voting country, and each column corresponds to a performance that was voted for. The list country_names gives the name of each voting country. This dataset was obtained from Eurovision.
Bu egzersiz
Unsupervised Learning in Python
kursunun bir parçasıdırEgzersiz talimatları
- Import
linkageanddendrogramfromscipy.cluster.hierarchy. - Perform hierarchical clustering on
samplesusing thelinkage()function with themethod='single'keyword argument. Assign the result tomergings. - Plot a dendrogram of the hierarchical clustering, using the list
country_namesas thelabels. In addition, specify theleaf_rotation=90, andleaf_font_size=6keyword arguments as you have done earlier.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Perform the necessary imports
import matplotlib.pyplot as plt
from ____ import ____, ____
# Calculate the linkage: mergings
mergings = ____
# Plot the dendrogram
____
plt.show()