def set_workload(self, W): marg = approximation.marginals_approx(W) self.workload = marg d = len(self.domain) A = np.arange(2**d) weights = marg.weight_vector() self.dphi = np.array( [np.dot(weights**2, self.mult[A | b]) for b in range(2**d)])
import approximation import implicit eps = 0.1 X, Xs = pickle.load( open('/home/ryan/Desktop/privbayes_data/census-%.1f.pkl' % eps, 'rb')) diffs = [(X - Y).sum(axis=3).flatten() for Y in Xs] dims = [[0], [1], [2], [4]] sf1 = CensusSF1().project_and_merge(dims) approx = CensusSF1Approx().project_and_merge(dims) proj = CensusSF1Projected().project_and_merge(dims) proj2 = CensusSF1().unique_project().project_and_merge(dims) kifer = CensusKifer().project_and_merge(dims) marginals = approximation.marginals_approx(sf1) eye = [np.eye(n) for n in sf1.domain] t0 = time.time() A_sf1 = optimize.restart_union_kron(sf1, 50, [1, 1, 8, 10]) t1 = time.time() A_approx = optimize.restart_union_kron(approx, 50, [1, 1, 8, 10]) t2 = time.time() A_proj = optimize.restart_kron(proj, 50, [1, 1, 8, 10]) t3 = time.time() A_kifer = optimize.restart_kron(kifer, 50, [1, 1, 1, 10]) t4 = time.time() A_proj2 = optimize.restart_kron(proj2, 50, [1, 1, 8, 10]) A_marg, A1_marg = optimize.restart_marginals(marginals, 50) err1 = sf1.expected_error(eye, eps)