Clustering data from classes