An implementation of the kmeans clustering algorithm