Exemple #1
0
 def test_dbscan(self):
     distances = CondensedMatrix([ 0., 0., 2., 2., 
                                      0., 2., 2.,
                                         2., 2.,
                                            0.])
     dbscan_alg = DBSCANAlgorithm(distances)
     eps = 1.0
     minpts = 2
     clustering = dbscan_alg.perform_clustering(kwargs = {"eps":eps, "minpts":minpts})
     expected = [1, 1, 1]
     self.assertItemsEqual(clustering.gen_class_list(starts_with = 1), expected)
     dbscan_alg.element_class = [PointClassType.UNCLASSIFIED]*5
     eps = 1.0
     minpts = 1
     clustering = dbscan_alg.perform_clustering(kwargs = {"eps":eps, "minpts":minpts})
     self.assertItemsEqual(clustering.gen_class_list(starts_with = 1),[1, 1, 1, 2, 2])
Exemple #2
0
 def test_dbscan_regression_mini(self):
     distances = CondensedMatrix([    12.36931688,   5.83095189,   9.43398113,  12.52996409,  15.65247584,  17.4642492,    
                                                     9.21954446,   4.47213595,   3.16227766,   4.47213595,   5.65685425,   
                                                                   5.,           8.06225775,  11.18033989,  13.15294644,
                                                                                 3.16227766,   6.32455532,   8.24621125,   
                                                                                               3.16227766,   5.09901951,   
                                                                                                             2.  ])
     dbscan_alg = DBSCANAlgorithm(distances)
     clustering = dbscan_alg.perform_clustering(kwargs = {"eps":4.0, "minpts":3})
     self.assertItemsEqual(clustering.gen_class_list(starts_with = 1),[-1, 1, -1, 1, 1, 1]) #[0, 1, 0, 1, 1, 1, 0]
Exemple #3
0
 def test_dbscan(self):
     distances = CondensedMatrix([0., 0., 2., 2., 0., 2., 2., 2., 2., 0.])
     dbscan_alg = DBSCANAlgorithm(distances)
     eps = 1.0
     minpts = 2
     clustering = dbscan_alg.perform_clustering(kwargs={
         "eps": eps,
         "minpts": minpts
     })
     expected = [1, 1, 1]
     self.assertItemsEqual(clustering.gen_class_list(starts_with=1),
                           expected)
     dbscan_alg.element_class = [PointClassType.UNCLASSIFIED] * 5
     eps = 1.0
     minpts = 1
     clustering = dbscan_alg.perform_clustering(kwargs={
         "eps": eps,
         "minpts": minpts
     })
     self.assertItemsEqual(clustering.gen_class_list(starts_with=1),
                           [1, 1, 1, 2, 2])
Exemple #4
0
 def test_dbscan_regression_mini(self):
     distances = CondensedMatrix([
         12.36931688, 5.83095189, 9.43398113, 12.52996409, 15.65247584,
         17.4642492, 9.21954446, 4.47213595, 3.16227766, 4.47213595,
         5.65685425, 5., 8.06225775, 11.18033989, 13.15294644, 3.16227766,
         6.32455532, 8.24621125, 3.16227766, 5.09901951, 2.
     ])
     dbscan_alg = DBSCANAlgorithm(distances)
     clustering = dbscan_alg.perform_clustering(kwargs={
         "eps": 4.0,
         "minpts": 3
     })
     self.assertItemsEqual(clustering.gen_class_list(starts_with=1),
                           [-1, 1, -1, 1, 1, 1])  #[0, 1, 0, 1, 1, 1, 0]