Determining Optimal K using Elbow Method
Experiment
Determining Optimal K using Elbow Method
๐ฏ Objective
To determine the optimal number of clusters (K) for a dataset using the Elbow Method.
๐ Theory
๐น Why do we need Elbow Method?
In K-Means, we must predefine K, but:
- Too small K → underfitting
- Too large K → overfitting
The Elbow Method helps choose the best K.
๐น What is Elbow Method?
It calculates the Within-Cluster Sum of Squares (WCSS) for different values of K.
๐น WCSS Formula
๐น Working Principle
- Run K-Means for different values of K (e.g., 1 to 10)
- Compute WCSS (inertia)
- Plot K vs WCSS
-
Identify the “elbow point”:
- Where WCSS starts decreasing slowly
๐งพ Sample Dataset
| Point | X | Y |
|---|---|---|
| P1 | 2 | 3 |
| P2 | 3 | 4 |
| P3 | 3 | 3 |
| P4 | 8 | 7 |
| P5 | 7 | 8 |
| P6 | 8 | 8 |
| P7 | 25 | 30 |
๐ป Program (Python Code)
๐ Output
๐น WCSS Values (Example)
๐ Graph Interpretation
- The curve drops sharply initially
- After a certain K, the decrease slows
- The “bend” or elbow point indicates optimal K
๐ For this dataset, the elbow is typically at:
✅ K = 3
๐ Result
The optimal number of clusters was determined using the Elbow Method, and the best value of K is found to be:
K = 3- Elbow Method helps select appropriate K
- Uses WCSS as evaluation metric
- Easy to implement and visualize

Comments
Post a Comment