Implement kmeans related code used to group work phases