예제 #1
0
    def test_client_interaction_NLS(self):
        laplace = Laplace(self.A, self.eps_share)
        ans = laplace.measure(self.X, self.prng)

        non_neg_least_squares = NonNegativeLeastSquares()
        x_est = non_neg_least_squares.infer(self.A, ans)
        self.assertEqual(self.X.shape, x_est.shape)
예제 #2
0
    def test_client_interaction_LS(self):
        laplace = Laplace(self.A, self.eps_share)
        ans = laplace.measure(self.X, self.prng)
        least_squares = LeastSquares()
        x_est = least_squares.infer(self.A, ans)

        self.assertEqual(self.X.shape, x_est.shape)
예제 #3
0
    def test_client_interaction_WNLS(self):
        laplace = Laplace(self.A, self.eps_share)
        ans = laplace.measure(self.X, self.prng)

        engine = WorkloadNonNegativeLeastSquares(self.A)
        x_est = engine.infer(self.A, ans)
        self.assertEqual(self.X.shape, x_est.shape)
예제 #4
0
    def test_client_interaction_MW(self):
        laplace = Laplace(self.A, self.eps_share)
        ans = laplace.measure(self.X, self.prng)
        x_est_init = np.random.rand(self.n)

        mult_weight = MultiplicativeWeights()
        x_est = mult_weight.infer(self.A, ans, x_est_init)
        self.assertEqual(self.X.shape, x_est.shape)
예제 #5
0
    def test_laplace_operator(self):
        laplace = Laplace(self.A, self.eps_share)
        actual_meas = laplace.measure(self.X, np.random.RandomState(self.seed))

        prng = np.random.RandomState(self.seed)
        target_meas = self.n + prng.laplace(0.0, self.n / self.eps_share,
                                            self.n)

        np.testing.assert_array_equal(target_meas, actual_meas)
예제 #6
0
    def test_client_interaction_HR(self):
        laplace = Laplace(self.A, self.eps_share)
        ans = laplace.measure(self.X, self.prng)
        eps_par = 0.1
        eta = 0.35
        ratio = 0.85

        AHP_threshold = AHPThresholding(eta, ratio)
        x_est = AHP_threshold.infer(self.A, ans, eps_par)
        self.assertEqual(self.X.shape, x_est.shape)