Exemplo n.º 1
0
    def evaluate(self, clustering, condensed_distance_matrix, cohesions = None):
        all_clusters = clustering.clusters

        my_cohesions_dic = {}
        if (cohesions is None):
            #Calculate_cohesions if not given
            cohesion_calctor = CohesionCalculator()
            for cluster in all_clusters:
                my_cohesions_dic[cluster] =  cohesion_calctor.evaluate_cluster(cluster, condensed_distance_matrix)
        else:
            for i, cluster in enumerate(all_clusters):
                my_cohesions_dic[cluster] = cohesions[i]

        total_separation = 0
        for i, cluster in enumerate(all_clusters):
            separation = self.cluster_separation(cluster, clustering, my_cohesions_dic[cluster], condensed_distance_matrix)
            total_separation = total_separation + separation

        return total_separation