コード例 #1
0
ファイル: ClusterRanker.py プロジェクト: MLDroid/chucky-old
 def rankingFromClusters(self, clusters):
     ranking = []
     for cluster in clusters:
         cluster = self.reorderInCluster(cluster)
         cluster = normalize(cluster)
         print ' ==== Cluster ====='
         for member in cluster:
             print member
             ranking.append(member)
     ranking.sort(reverse=True)
     return averageRanking(ranking)
コード例 #2
0
 def rankingFromClusters(self, clusters):
     ranking = []
     for cluster in clusters:
         cluster = self.reorderInCluster(cluster)
         cluster = normalize(cluster)
         print ' ==== Cluster ====='
         for member in cluster:
             print member
             ranking.append(member)
     ranking.sort(reverse=True)
     return averageRanking(ranking)
コード例 #3
0
ファイル: ClusterRanker.py プロジェクト: MLDroid/chucky-old
 def rankingFromClustersDrawMethod(self, clusters):
     outliers = [c for c in clusters if len(c) <= 0]
     clusters = [(len(c), -c[0][0], c) for c in clusters if len(c) > 0]
     
     clusters.sort()
     clusters = [c[2] for c in clusters]
     
     globalRanking = []
     
     while len(clusters) != 0:
         currentCluster = clusters.pop(0)
         if len(currentCluster) == 0:
             continue
         globalRanking.append(currentCluster.pop(0))
         if len(currentCluster) != 0:
             clusters.append(currentCluster)
         
     for outlierCluster in outliers:
         for member in outlierCluster:
             globalRanking.append(member)
     
     ranking = averageRanking(globalRanking)
     return ranking
コード例 #4
0
    def rankingFromClustersDrawMethod(self, clusters):
        outliers = [c for c in clusters if len(c) <= 0]
        clusters = [(len(c), -c[0][0], c) for c in clusters if len(c) > 0]

        clusters.sort()
        clusters = [c[2] for c in clusters]

        globalRanking = []

        while len(clusters) != 0:
            currentCluster = clusters.pop(0)
            if len(currentCluster) == 0:
                continue
            globalRanking.append(currentCluster.pop(0))
            if len(currentCluster) != 0:
                clusters.append(currentCluster)

        for outlierCluster in outliers:
            for member in outlierCluster:
                globalRanking.append(member)

        ranking = averageRanking(globalRanking)
        return ranking