Exemplo n.º 1
0
    def Run(self, W, x, eps, seed):
        x = x.flatten()
        prng = np.random.RandomState(seed)

        if self.workload_based:
            mapping = mapper.WorkloadBased(W).mapping()
            reducer = transformation.ReduceByPartition(mapping)
            x = reducer.transform(x)
            # Reduce workload
            # W = support.reduce_queries(mapping, W)
            W = W * support.expansion_matrix(mapping)

        # Orange AHPparition(PA) operator in paper can be expressed
        # as the following sequence of simpler opeartors
        M = selection.Identity(x.shape).select()
        y = measurement.Laplace(M, self.ratio * eps).measure(x, prng)
        xest = inference.AHPThresholding(self.eta, self.ratio).infer(M, y, eps)
        mapping = mapper.AHPCluster(xest, (1 - self.ratio) * eps).mapping()

        # TR
        reducer = transformation.ReduceByPartition(mapping)

        x_bar = reducer.transform(x)
        # SI LM LS
        M_bar = selection.Identity(x_bar.shape).select()
        y_bar = measurement.Laplace(M_bar, eps * (1 - self.ratio)).measure(
            x_bar, prng)
        x_bar_hat = inference.LeastSquares().infer(M_bar, y_bar)
        x_hat = support.expansion_matrix(mapping) * x_bar_hat

        return x_hat
Exemplo n.º 2
0
    def ahp_partition(self, n, ratio, eta, eps):
        M = selection.Identity((n, )).select()
        y = self.laplace(M, ratio * eps)
        xest = inference.AHPThresholding(eta, ratio).infer(M, y, eps)

        return mapper.AHPCluster(xest, (1 - ratio) * eps).mapping()