Determining Optimal K using Silhouette Method
Experiment
Determining Optimal K using Silhouette Method
๐ฏ Objective
To determine the optimal number of clusters (K) using the Silhouette Method.
๐ Theory
๐น Why Silhouette Method?
Unlike the Elbow Method, which may be ambiguous, the Silhouette Method provides a quantitative measure of clustering quality.
๐น Silhouette Score
It measures how well each data point fits within its cluster.
- a(i) = average distance to points in same cluster
- b(i) = average distance to points in nearest cluster
๐น Silhouette Formula
๐น Interpretation
| Score | Meaning |
|---|---|
| ≈ 1 | Well clustered |
| ≈ 0 | Overlapping clusters |
| < 0 | Misclassified |
๐น Working Principle
- Run K-Means for different values of K
- Compute average silhouette score
- Choose K with highest score
๐งพ Sample Dataset
| Point | X | Y |
|---|---|---|
| P1 | 2 | 3 |
| P2 | 3 | 4 |
| P3 | 3 | 3 |
| P4 | 8 | 7 |
| P5 | 7 | 8 |
| P6 | 8 | 8 |
| P7 | 15 | 16 |
P9 15 15
๐ป Program (Python Code)
๐Output
K = 2, Silhouette Score = 0.7519172781342643 K = 3, Silhouette Score = 0.8503109587689267 K = 4, Silhouette Score = 0.5843521134750496 K = 5, Silhouette Score = 0.33839040555236954 K = 6, Silhouette Score = 0.30584671457309703
๐ Graph Interpretation
- The value of K with the highest silhouette score is optimal
- Graph shows peak at a specific K
๐ For this dataset:
✅ Optimal K = 3
๐ Result
Using the Silhouette Method, the optimal number of clusters was found to be:
K = 3
- Silhouette Method provides a clear numerical metric
- More reliable than Elbow Method in many cases
- Helps evaluate clustering quality

Comments
Post a Comment