Challenge - 5 Problems
K-Means Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateUnderstanding the K-Means Objective
What is the main goal of the K-Means clustering algorithm?
Attempts:
2 left
💡 Hint
Think about how K-Means groups points close to each other.
✗ Incorrect
K-Means aims to find cluster centers that minimize the sum of squared distances from each point to its nearest center, creating tight groups.
❓ Predict Output
intermediateOutput of K-Means Cluster Assignments
What is the output of the following Python code snippet using scikit-learn's KMeans?
ML Python
from sklearn.cluster import KMeans import numpy as np X = np.array([[1, 2], [1, 4], [1, 0], [10, 2], [10, 4], [10, 0]]) kmeans = KMeans(n_clusters=2, random_state=0).fit(X) print(kmeans.labels_)
Attempts:
2 left
💡 Hint
Look at how points are grouped by proximity.
✗ Incorrect
The first three points are close together and assigned to cluster 0, the last three to cluster 1.
❓ Hyperparameter
advancedChoosing the Number of Clusters (k)
Which method is commonly used to decide the best number of clusters (k) in K-Means clustering?
Attempts:
2 left
💡 Hint
Think about a plot that shows diminishing returns.
✗ Incorrect
The elbow method plots the sum of squared distances for different k values and looks for a point where improvement slows down.
❓ Metrics
advancedEvaluating K-Means Clustering Quality
Which metric measures how well-separated the clusters are in K-Means clustering?
Attempts:
2 left
💡 Hint
This metric ranges from -1 to 1 and considers cohesion and separation.
✗ Incorrect
Silhouette score measures how similar a point is to its own cluster compared to other clusters, indicating cluster separation.
🔧 Debug
expertDebugging K-Means Convergence Issue
You run K-Means on a dataset but notice the algorithm does not converge and runs indefinitely. Which is the most likely cause?
Attempts:
2 left
💡 Hint
Think about what happens if clusters cannot be assigned uniquely.
✗ Incorrect
If k is larger than unique points, some clusters have no points, causing the algorithm to fail to update centers and not converge.
