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