0
0
ML Pythonml~10 mins

Why advanced clustering finds complex structures in ML Python - Test Your Understanding

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

Complete the code to import the clustering algorithm.

ML Python
from sklearn.cluster import [1]
Drag options to blanks, or click blank then click option'
AKMeans
Btrain_test_split
CLinearRegression
DPCA
Attempts:
3 left
💡 Hint
Common Mistakes
Importing train_test_split instead of a clustering algorithm.
Confusing clustering with regression or PCA.
2fill in blank
medium

Complete the code to fit the clustering model on data X.

ML Python
model = KMeans(n_clusters=3)
model.[1](X)
Drag options to blanks, or click blank then click option'
Ascore
Bpredict
Ctransform
Dfit
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict before fitting the model.
Using transform which is for dimensionality reduction.
3fill in blank
hard

Fix the error in the code to predict cluster labels.

ML Python
labels = model.[1](X)
Drag options to blanks, or click blank then click option'
Apredict
Btransform
Cfit
Dfit_predict
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit instead of predict to get labels.
Using transform which changes data representation.
4fill in blank
hard

Fill both blanks to create a dictionary of cluster sizes.

ML Python
cluster_sizes = {i: sum(labels [1] i) for i in range([2])}
Drag options to blanks, or click blank then click option'
A==
B!=
C3
Dlen(labels)
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' causes wrong counts.
Using len(labels) instead of number of clusters in range.
5fill in blank
hard

Fill all three blanks to filter data points in cluster 1 with feature > 5.

ML Python
filtered = [x for x, label in zip(X, labels) if label == [1] and x[[2]] [3] 5]
Drag options to blanks, or click blank then click option'
A0
B1
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong cluster label number.
Using wrong feature index.
Using '<' instead of '>' for filtering.