Input: Dataset |
Output: Clusters, Centroids |
() Set , = First instance |
() For every instance Dataset and Do |
() If , Then |
() , |
() Assign every instance Dataset to the closest centroid to make clusters |
() Calculate cluster centroids , |
() For every instance Dataset Do |
() Reassign to closest cluster centroid; is moved from to |
If , . |
() Recalculate centroids for clusters and . |
() If cluster instances are stabilized then stop, Else go to Step (). |