Пример #1
0
    def test_regression_cohesion_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)

        cohesion_calctor = CohesionCalculator()
        self.assertEqual(cohesion_calctor.evaluate(clustering, distances), 5.5)
Пример #2
0
 def test_regression_cohesion_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)
     
     cohesion_calctor = CohesionCalculator()
     self.assertEqual( cohesion_calctor.evaluate(clustering, distances), 5.5)
Пример #3
0
    def test_cluster_cohesion_without_prototype(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])
        ]

        cohesion_calctor = CohesionCalculator()

        self.assertEqual(
            cohesion_calctor.evaluate_cluster(clusters_1[0], distances), 0.5)
        self.assertEqual(
            cohesion_calctor.evaluate_cluster(clusters_1[1], distances), 0.)
        self.assertEqual(
            cohesion_calctor.evaluate_cluster(clusters_1[2], distances), 5.0)
        self.assertEqual(
            cohesion_calctor.evaluate_cluster(clusters_2[0], distances), 5.0)
        self.assertEqual(
            cohesion_calctor.evaluate_cluster(clusters_2[1], distances), 3.0)
Пример #4
0
 def test_cluster_cohesion_without_prototype(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])]
     
     cohesion_calctor = CohesionCalculator()
     
     self.assertEqual(cohesion_calctor.evaluate_cluster(clusters_1[0],distances), 0.5)
     self.assertEqual(cohesion_calctor.evaluate_cluster(clusters_1[1],distances), 0.)
     self.assertEqual(cohesion_calctor.evaluate_cluster(clusters_1[2],distances), 5.0)
     self.assertEqual(cohesion_calctor.evaluate_cluster(clusters_2[0],distances), 5.0)
     self.assertEqual(cohesion_calctor.evaluate_cluster(clusters_2[1],distances), 3.0)