Complete the code to import the KMeans class from scikit-learn.
from sklearn.cluster import [1]
The KMeans class is used for K-Means clustering in scikit-learn.
Complete the code to create a KMeans model with 3 clusters.
model = KMeans(n_clusters=[1])Setting n_clusters=3 tells the model to find 3 clusters.
Fix the error in the code to fit the KMeans model on data X.
model.[1](X)The fit() method trains the KMeans model on the data.
Fill both blanks to create a dictionary of cluster labels for each data point.
labels_dict = {i: model.[1][i] for i in range([2])}model.labels_ gives the cluster label for each point. range(len(X)) iterates over data points.
Fill all three blanks to compute and print the silhouette score for the clustering.
from sklearn.metrics import [1] score = [2](X, model.[3]) print('Silhouette Score:', score)
silhouette_score is imported and called with data X and cluster labels model.labels_.
