Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
2fill in blank
mediumComplete 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'
Attempts:
3 left
3fill in blank
hardFix 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'
Attempts:
3 left
4fill in blank
hardFill 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'
Attempts:
3 left
5fill in blank
hardFill 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'
Attempts:
3 left