Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Clustering and Distance
What will be the output of this code snippet?
from sklearn.metrics import silhouette_score
labels = [0, 0, 1, 1]
data = [[1, 2], [2, 1], [8, 9], [9, 8]]
score = silhouette_score(data, labels)
print(round(score, 2))
A0.00
B0.86
C-0.50
D1.00
Step-by-Step Solution
Solution:
  1. Step 1: Understand silhouette_score calculation

    Silhouette score measures how well clusters are separated; here clusters are well separated.
  2. Step 2: Calculate or recall typical score for this data

    Points in cluster 0 are close, cluster 1 points are close, and clusters are far apart, so score is positive and high.
  3. Final Answer:

    0.86 -> Option B
  4. Quick Check:

    Silhouette score output = B [OK]
Quick Trick: Well-separated clusters give silhouette score near 1 [OK]
Common Mistakes:
  • Expecting silhouette score to be zero or negative
  • Confusing silhouette score with accuracy
  • Ignoring cluster label correctness

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes