def setUp(self):
        n_points_per_cluster = 250
        np.random.seed(0)
        C1 = np.zeros((n_points_per_cluster, 3))
        C2 = np.zeros((n_points_per_cluster, 3))
        C3 = np.zeros((n_points_per_cluster, 3))
        C4 = np.zeros((n_points_per_cluster, 3))
        C5 = np.zeros((n_points_per_cluster, 3))
        C6 = np.zeros((n_points_per_cluster, 3))
        C1[:, 1:3] = ([-5, -2] + .8 * np.random.randn(n_points_per_cluster, 2))
        C2[:, 1:3] = ([4, -1] + .1 * np.random.randn(n_points_per_cluster, 2))
        C3[:, 1:3] = ([0, -2] + .2 * np.random.randn(n_points_per_cluster, 2))
        C4[:, 1:3] = ([-2, 3] + .3 * np.random.randn(n_points_per_cluster, 2))
        C5[:, 1:3] = ([3, -2] + 1.6 * np.random.randn(n_points_per_cluster, 2))
        C6[:, 1:3] = ([5, 6] + 2 * np.random.randn(n_points_per_cluster, 2))
        X = np.vstack(
            (C1[:, 1:3], C2[:, 1:3], C3[:, 1:3], C4[:, 1:3], C5[:,
                                                                1:3], C6[:,
                                                                         1:3]))

        clust = OPTICS(min_samples=50, xi=.05, min_cluster_size=.05)
        # Run the fit
        clust.fit(X)
        self.tbhg = modeling.TBH()
        self.tbhg.optics = clust
        self.tbhg.locH = (C1, C2, C3, C4, C5, C6)
        # self.tbhg = TBHG(clust)
        pass
 def test_build_hierarchy(self):
     tbhg = modeling.TBH()
     optics = OPTICS_()
     optics.cluster_hierarchy_ = [[0, 4], [6, 8], [5, 8], [8, 10], [0, 10]]
     optics.ordering_ = [x for x in range(11)]
     tbhg.optics = optics
     r = tbhg._build_tree()
     h = tbhg._build_hierarchy(r)
     for i in h:
         print(i)
Beispiel #3
0
def build_tbh(optics, locH):
    return modeling.TBH(optics, locH)
Beispiel #4
0
def build_tree(optics):
    tbhg = modeling.TBH()
    tbhg.optics = optics
    return tbhg._build_tree()
Beispiel #5
0
def build_hierarchy(optics):
    tbhg = modeling.TBH(optics)
    return tbhg.hierarchy