An efficient implementation of KMeans clustering algorithm