0
0
ML Pythonprogramming~10 mins

K-Means 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 KMeans class from scikit-learn.

ML Python
from sklearn.cluster import [1]
Drag options to blanks, or click blank then click option'
AKMeans
BLinearRegression
CDecisionTreeClassifier
DRandomForest
Attempts:
3 left
2fill in blank
medium

Complete the code to create a KMeans model with 3 clusters.

ML Python
model = KMeans(n_clusters=[1])
Drag options to blanks, or click blank then click option'
A10
B1
C5
D3
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to fit the KMeans model on data X.

ML Python
model.[1](X)
Drag options to blanks, or click blank then click option'
Afit
Bpredict
Ctransform
Dscore
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a dictionary of cluster labels for each data point.

ML Python
labels_dict = {i: model.[1][i] for i in range([2])}
Drag options to blanks, or click blank then click option'
Alabels_
Blen(X)
Ccluster_centers_
Dinertia_
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to compute and print the silhouette score for the clustering.

ML Python
from sklearn.metrics import [1]
score = [2](X, model.[3])
print('Silhouette Score:', score)
Drag options to blanks, or click blank then click option'
Asilhouette_score
Blabels_
Cpredict
Dfit_predict
Attempts:
3 left