Beispiel #1
0
    def test_get_partition_vec(self):
        n = 8
        rank = list(range(n))
        rank.reverse()
        cluster = [[0,4],[4,8]]

        np.testing.assert_array_equal(support.get_partition_vec(rank, n, cluster, closeRange=False),
                                      np.array([1,1,1,1,0,0,0,0]))
Beispiel #2
0
    def mapping(self, X, prng):
        pseed = prng.randint(500000)

        if self.approx:
            cluster = l1partition.L1partition_approx(X, self.eps, ratio=self.ratio, gethist=True, seed=pseed)
        else:
            cluster = l1partition.L1partition(X, self.eps, ratio=self.ratio, gethist=True, seed=pseed)

        return support.get_partition_vec(None, len(X), cluster, closeRange=True)
Beispiel #3
0
    def mapping(self):
        # sort
        rank = self.get_rank()
        sorted_xest = np.sort(self.xest)

        # clustering
        cluster = ahp_fast.greedy_cluster(sorted_xest, self.eps_par)
        partition_vec = support.get_partition_vec(rank,
                                                  len(sorted_xest),
                                                  cluster,
                                                  closeRange=False)

        return partition_vec