Esempio n. 1
0
 def test_mini_evaluation(self):
     calculator = MeanMinimumDistanceCalculator(10)
     clusters = [
         Cluster(None, elements=[0, 1, 2]),
         Cluster(None, elements=[3, 4])
     ]
     triangle = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]
     distances = CondensedMatrix(triangle)
     clustering = Clustering(clusters)
     self.assertEqual(7.0, calculator.evaluate(clustering, distances, 20))
Esempio n. 2
0
 def test_mini_evaluation(self):
     calculator = MeanMinimumDistanceCalculator(10)
     clusters = [Cluster(None, elements=[0,1,2]),
                 Cluster(None, elements=[3,4])]
     triangle = [ 1., 2., 3., 4., 
                      5., 6., 7., 
                          8., 9., 
                             10.]
     distances =  CondensedMatrix( triangle )
     clustering = Clustering(clusters)
     self.assertEqual(7.0, calculator.evaluate(clustering,distances,20))
Esempio n. 3
0
 def test_full_run(self):
     condensed_matrix = CondensedMatrix(matrix)
     cmax = condensed_matrix.calculateMax()
     alg = RandomAlgorithm.RandomClusteringAlgorithm(condensed_matrix)
     values = []
     calculator =  MeanMinimumDistanceCalculator(10)
     for i in range(2,20):
         clustering = alg.perform_clustering({
                                              "max_num_of_clusters":-1, 
                                              "num_clusters":i
                                              })
         values.append( calculator.evaluate(clustering, condensed_matrix, 30))
     self.assertTrue(max(values) < cmax)
Esempio n. 4
0
 def test_full_run(self):
     condensed_matrix = CondensedMatrix(matrix)
     cmax = condensed_matrix.calculateMax()
     alg = RandomAlgorithm.RandomClusteringAlgorithm(condensed_matrix)
     values = []
     calculator = MeanMinimumDistanceCalculator(10)
     for i in range(2, 20):
         clustering = alg.perform_clustering({
             "max_num_of_clusters": -1,
             "num_clusters": i
         })
         values.append(calculator.evaluate(clustering, condensed_matrix,
                                           30))
     self.assertTrue(max(values) < cmax)