Perform k-means clustering