0
0
SciPydata~10 mins

Hierarchical clustering (linkage) in SciPy - 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 function for hierarchical clustering linkage.

SciPy
from scipy.cluster.hierarchy import [1]
Drag options to blanks, or click blank then click option'
Adendrogram
Bcophenet
Cfcluster
Dlinkage
Attempts:
3 left
💡 Hint
Common Mistakes
Importing dendrogram instead of linkage
Importing fcluster which is for flat clusters
Importing cophenet which measures cluster quality
2fill in blank
medium

Complete the code to perform linkage clustering on data using the 'ward' method.

SciPy
Z = linkage(data, method=[1])
Drag options to blanks, or click blank then click option'
A'ward'
B'average'
C'complete'
D'single'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'single' which links based on minimum distance
Using 'complete' which links based on maximum distance
Using 'average' which links based on average distance
3fill in blank
hard

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

SciPy
dendrogram([1])
Drag options to blanks, or click blank then click option'
Alinkage
BZ
Cdata
Dmethod
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw data instead of linkage matrix
Passing the function name instead of its output
Passing the method name as argument
4fill in blank
hard

Fill both blanks to create a linkage matrix using 'complete' method and plot its dendrogram.

SciPy
Z = linkage(data, method=[1])
dendrogram([2])
Drag options to blanks, or click blank then click option'
A'complete'
B'single'
CZ
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw data to dendrogram
Using wrong method string
Confusing linkage matrix variable with data
5fill in blank
hard

Fill all three blanks to compute linkage with 'average' method, plot dendrogram, and set color threshold to 1.5.

SciPy
Z = linkage(data, method=[1])
dendrogram(Z, color_threshold=[2], [3]=True)
Drag options to blanks, or click blank then click option'
A'average'
B1.5
Cabove_threshold_color
Dshow_leaf_counts
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method string
Setting color_threshold to a string
Using wrong parameter name for showing leaf counts