0
0
SciPydata~10 mins

Dendrogram visualization 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 needed to create a dendrogram.

SciPy
from scipy.cluster.hierarchy import [1]
Drag options to blanks, or click blank then click option'
Adendrogram
Blinkage
Cfcluster
Dcophenet
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'linkage' instead of 'dendrogram'.
Trying to import from the wrong module.
2fill in blank
medium

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

SciPy
Z = linkage(data, method=[1])
Drag options to blanks, or click blank then click option'
A'average'
B'complete'
C'single'
D'ward'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'single' which can produce chaining effect.
Using 'average' which is less common for dendrograms.
3fill in blank
hard

Fix the error in the code to plot the dendrogram correctly.

SciPy
plt.figure(figsize=(10, 5))
dendrogram([1])
plt.show()
Drag options to blanks, or click blank then click option'
Adata
BZ
Clinkage
Ddendrogram
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw data instead of linkage matrix.
Passing the dendrogram function itself.
4fill in blank
hard

Fill both blanks to create a dendrogram with labels and a color threshold.

SciPy
dendrogram([1], labels=[2], color_threshold=1.5)
Drag options to blanks, or click blank then click option'
AZ
Blabels
Cdata
Dlinkage
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw data instead of linkage matrix.
Passing data instead of labels for the labels argument.
5fill in blank
hard

Fill all three blanks to create and plot a dendrogram with orientation and truncate mode.

SciPy
plt.figure(figsize=(8, 6))
dendrogram([1], orientation=[2], truncate_mode=[3])
plt.show()
Drag options to blanks, or click blank then click option'
AZ
B'top'
C'lastp'
D'right'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong orientation like 'right' which changes the dendrogram direction.
Not using truncate_mode or using an invalid value.