Python implementation of kmeans algorithm