15/10/26 Thu 8:05am
K- Means Clustering
Is an unsupervised learning algorithm that divides the observations into k groups based on similarity. Observations within a group are close to one another in the selected feature space.
Steps for k-means clustering algorithm.
- Select the number of clusters
- Choose the initial centroids of the cluster
- Calculate each observation distance from every centroid
- Assign each observation to its nearest centroid/cluster
- Recalculate each centroid
- Repeat Step Three to Five until the maximum iteration count is reached
where the centroid is given by:
QnA
Q1
Question
A pump generates two features without labels, the observations for the historical data are as given below
Divide these features into two clusters with initial centroids as (1,1) and (3,1)
| Flow Feature | Pressure Feature | ||
|---|---|---|---|
| P1 | 1 | 1 | ✅ |
| P2 | 1 | 3 | |
| P3 | 3 | 1 | ✅ |
| P4 | 7 | 7 | |
| P5 | 7 | 9 | |
| P6 | 9 | 7 |
Soln
| Distance to (1,1) | Distance to (3,1) | |
|---|---|---|
| P2 (1,3) | 2 | 2.8284 |
| P4 (7,7) | 8.4852 | 7.211 |
| P5 (7,9) | 10 | 8.9442 |
| P6 (9,7) | 10 | 8.4852 |
venn-beta title Cluster set A[P1,P2] set B[P3,P4,P5,P6]
The new centroids are