コード例 #1
0
ファイル: TestMetrics.py プロジェクト: migonsu/pyProCT
 def test_regression_separation_eval(self):
     distances =  CondensedMatrix( [ 1., 2., 3., 4.,
                                         5., 6., 7., 
                                             8., 9., 
                                                10.])
     clusters = [Cluster(None, elements=[0,1]),
                 Cluster(None, elements=[2]),
                 Cluster(None, elements=[3,4])]
     clustering = Clustering(clusters)
     
     sep_calctor = SeparationCalculator()
     self.assertEqual( sep_calctor.evaluate(clustering, distances,[1,1,1]), 27.0 + 24.0 + 37.0)
     self.assertEqual( sep_calctor.evaluate(clustering, distances), (1/0.5)*27.0 + (1/5.0)*37.0)
コード例 #2
0
ファイル: TestMetrics.py プロジェクト: ztypaker/pyProCT
    def test_regression_separation_eval(self):
        distances = CondensedMatrix([1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
        clusters = [
            Cluster(None, elements=[0, 1]),
            Cluster(None, elements=[2]),
            Cluster(None, elements=[3, 4])
        ]
        clustering = Clustering(clusters)

        sep_calctor = SeparationCalculator()
        self.assertEqual(
            sep_calctor.evaluate(clustering, distances, [1, 1, 1]),
            27.0 + 24.0 + 37.0)
        self.assertEqual(sep_calctor.evaluate(clustering, distances),
                         (1 / 0.5) * 27.0 + (1 / 5.0) * 37.0)
コード例 #3
0
ファイル: TestMetrics.py プロジェクト: ztypaker/pyProCT
    def test_cluster_cohe_sep_wo_prot_eval(self):
        distances = CondensedMatrix([1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
        clusters_1 = [
            Cluster(None, elements=[0, 1]),
            Cluster(None, elements=[2]),
            Cluster(None, elements=[3, 4])
        ]

        clusters_2 = [
            Cluster(None, elements=[0, 2, 4]),
            Cluster(None, elements=[1, 3])
        ]

        clusterization_1 = Clustering(clusters_1)
        clusterization_2 = Clustering(clusters_2)
        sep_calctor = SeparationCalculator()

        self.assertEqual(
            sep_calctor.cluster_separation(clusters_1[0], clusterization_1, 1.,
                                           distances), 27.0)
        self.assertEqual(
            sep_calctor.cluster_separation(clusters_1[1], clusterization_1, 1.,
                                           distances), 24.0)
        self.assertEqual(
            sep_calctor.cluster_separation(clusters_1[2], clusterization_1, 1.,
                                           distances), 37.0)
        self.assertEqual(
            sep_calctor.cluster_separation(clusters_2[0], clusterization_2, 1.,
                                           distances), 34.0)
        self.assertEqual(
            sep_calctor.cluster_separation(clusters_2[1], clusterization_2, 1.,
                                           distances), 34.0)
コード例 #4
0
ファイル: TestMetrics.py プロジェクト: migonsu/pyProCT
 def test_cluster_mixed_cohesion_wo_prot(self):
     
     distances =  CondensedMatrix( [ 1., 2., 3., 4.,
                                         5., 6., 7., 
                                             8., 9., 
                                                10.])
     clusters_1 = [Cluster(None, elements=[0,1]),
                   Cluster(None, elements=[2] ),
                   Cluster(None, elements=[3,4])]
     
     clusters_2 = [Cluster(None, elements=[0,2,4]),
                   Cluster(None, elements=[1,3])]
     
     sep_calctor = SeparationCalculator()
     
     self.assertEqual( sep_calctor._SeparationCalculator__between_cluster_distance(clusters_1[0],clusters_1[1],distances),7.0)
     self.assertEqual( sep_calctor._SeparationCalculator__between_cluster_distance(clusters_1[0],clusters_1[2],distances),20.0)
     self.assertEqual( sep_calctor._SeparationCalculator__between_cluster_distance(clusters_1[1],clusters_1[2],distances),17.0)
     self.assertEqual( sep_calctor._SeparationCalculator__between_cluster_distance(clusters_2[0],clusters_2[1],distances),34.0)
コード例 #5
0
ファイル: TestMetrics.py プロジェクト: migonsu/pyProCT
 def test_cluster_cohe_sep_wo_prot_eval(self):
     distances =  CondensedMatrix( [ 1., 2., 3., 4.,
                                         5., 6., 7., 
                                             8., 9., 
                                                10.])
     clusters_1 = [Cluster(None, elements=[0,1]),
                   Cluster(None, elements=[2] ),
                   Cluster(None, elements=[3,4])]
     
     clusters_2 = [Cluster(None, elements=[0,2,4]),
                   Cluster(None, elements=[1,3])]
     
     clusterization_1 = Clustering(clusters_1)
     clusterization_2 = Clustering(clusters_2)
     sep_calctor = SeparationCalculator()
     
     self.assertEqual(sep_calctor.cluster_separation(clusters_1[0],clusterization_1,1.,distances),27.0)
     self.assertEqual(sep_calctor.cluster_separation(clusters_1[1],clusterization_1,1.,distances),24.0)
     self.assertEqual(sep_calctor.cluster_separation(clusters_1[2],clusterization_1,1.,distances),37.0)
     self.assertEqual(sep_calctor.cluster_separation(clusters_2[0],clusterization_2,1.,distances),34.0)
     self.assertEqual(sep_calctor.cluster_separation(clusters_2[1],clusterization_2,1.,distances),34.0)
コード例 #6
0
ファイル: TestMetrics.py プロジェクト: ztypaker/pyProCT
    def test_cluster_mixed_cohesion_wo_prot(self):

        distances = CondensedMatrix([1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
        clusters_1 = [
            Cluster(None, elements=[0, 1]),
            Cluster(None, elements=[2]),
            Cluster(None, elements=[3, 4])
        ]

        clusters_2 = [
            Cluster(None, elements=[0, 2, 4]),
            Cluster(None, elements=[1, 3])
        ]

        sep_calctor = SeparationCalculator()

        self.assertEqual(
            sep_calctor._SeparationCalculator__between_cluster_distance(
                clusters_1[0], clusters_1[1], distances), 7.0)
        self.assertEqual(
            sep_calctor._SeparationCalculator__between_cluster_distance(
                clusters_1[0], clusters_1[2], distances), 20.0)
        self.assertEqual(
            sep_calctor._SeparationCalculator__between_cluster_distance(
                clusters_1[1], clusters_1[2], distances), 17.0)
        self.assertEqual(
            sep_calctor._SeparationCalculator__between_cluster_distance(
                clusters_2[0], clusters_2[1], distances), 34.0)