(self)
return [Cluster(instances=list(pair[1] for pair in group),
                        centroid=kmeans.cluster_centers_[l])
                for l, group in groupby(labels_attrs, key=lambda x: x[0])]
Generates groupes of attribute IDs, grouped by cluster. Clusters are
        obtained by KMeans algorithm.

        :return: generator of attributes grouped by cluster
Generates groupes of attribute IDs, grouped by cluster. Clusters are
        obtained by KMeans algorithm.
Generates groupes of attribute IDs grouped by cluster . Clusters are obtained by KMeans algorithm .
def get_clusters_of_attributes(self):
        """
        Generates groupes of attribute IDs, grouped by cluster. Clusters are
        obtained by KMeans algorithm.

        :return: generator of attributes grouped by cluster
        """
        data = Normalize()(self.data).X.T
        kmeans = KMeans(n_clusters=self.n_clusters, random_state=0).fit(data)
        labels_attrs = sorted([(l, i) for i, l in enumerate(kmeans.labels_)])
        return [Cluster(instances=list(pair[1] for pair in group),
                        centroid=kmeans.cluster_centers_[l])
                for l, group in groupby(labels_attrs, key=lambda x: x[0])]
def get_clusters_of_attributes ( self ) : data = Normalize ( ) ( self . data ) . X . T kmeans = KMeans ( n_clusters = self . n_clusters , random_state = 0 ) . fit ( data ) labels_attrs = sorted ( [ ( l , i ) for i , l in enumerate ( kmeans . labels_ ) ] ) return [ Cluster ( instances = list ( pair [ 1 ] for pair in group ) , centroid = kmeans . cluster_centers_ [ l ] ) for l , group in groupby ( labels_attrs , key = lambda x : x [ 0 ] ) ]