Challenge - 5 Problems
K-Means Clustering Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding the Elbow Method
When using the elbow method to choose the number of clusters K in K-means clustering, what does the 'elbow' point represent?
Attempts:
2 left
🧠 Conceptual
intermediate2:00remaining
Silhouette Score Interpretation
What does a silhouette score close to 1 indicate about the clustering quality?
Attempts:
2 left
❓ Predict Output
advanced2:00remaining
Output of Silhouette Score Calculation
What is the output of the following Python code snippet?
ML Python
from sklearn.datasets import make_blobs from sklearn.cluster import KMeans from sklearn.metrics import silhouette_score X, _ = make_blobs(n_samples=100, centers=3, cluster_std=0.5, random_state=42) model = KMeans(n_clusters=3, random_state=42) labels = model.fit_predict(X) score = silhouette_score(X, labels) print(round(score, 2))
Attempts:
2 left
❓ Metrics
advanced2:00remaining
Choosing K Using Silhouette Scores
You run K-means clustering for K values from 2 to 6 and get these silhouette scores: {2: 0.45, 3: 0.62, 4: 0.58, 5: 0.55, 6: 0.50}. Which K should you choose based on silhouette score?
Attempts:
2 left
🔧 Debug
expert3:00remaining
Identifying the Error in Elbow Method Plot Code
What error will this code raise when trying to plot the elbow curve?
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs
X, _ = make_blobs(n_samples=100, centers=4, random_state=0)
wcss = []
for k in range(1, 6):
model = KMeans(n_clusters=k)
model.fit(X)
wcss.append(model.inertia_)
plt.plot(range(1, 6), wcss)
plt.xlabel('Number of clusters')
plt.ylabel('WCSS')
plt.title('Elbow Method')
plt.show()Attempts:
2 left