0
0
ML Pythonprogramming~10 mins

Hierarchical clustering in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the correct function for hierarchical clustering.

ML Python
from scipy.cluster.hierarchy import [1]
Drag options to blanks, or click blank then click option'
Afit_predict
Btrain_test_split
Clinkage
Dkmeans
Attempts:
3 left
2fill in blank
medium

Complete the code to compute the linkage matrix using the 'ward' method.

ML Python
Z = linkage(data, method=[1])
Drag options to blanks, or click blank then click option'
A'average'
B'ward'
C'single'
D'complete'
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to plot a dendrogram from the linkage matrix.

ML Python
dendrogram([1])
plt.show()
Drag options to blanks, or click blank then click option'
Alinkage
Bdata
Cplt
DZ
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a dictionary of cluster labels for each sample using fcluster with a distance threshold.

ML Python
from scipy.cluster.hierarchy import fcluster
labels = fcluster([1], t=[2], criterion='distance')
Drag options to blanks, or click blank then click option'
AZ
Bdata
C5
D10
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to compute the linkage matrix, plot the dendrogram, and assign cluster labels with max clusters = 3.

ML Python
Z = [1](data, method='ward')
dendrogram([2])
labels = fcluster(Z, t=[3], criterion='maxclust')
Drag options to blanks, or click blank then click option'
Alinkage
BZ
C3
Dfcluster
Attempts:
3 left