def run_example(): n = 10**5 bucket_size = 100 epsilon = 1 print("==========>>>>> in KRR") krr = kRR(bucket_size=bucket_size, epsilon=epsilon) bucket_list, true_hist = example.generate_bucket(n=n, bucket_size=bucket_size, distribution_name='exp') print("this is buckets: ", bucket_list) print("this is true hist: ", true_hist) private_bucket_list = [krr.user_encode(item) for item in bucket_list] estimated_hist = krr.aggregate_histogram(private_bucket_list) print("this is estimate_hist", estimated_hist) estimated_hist_by_matrix = krr.aggregate_histogram_by_matrix( private_bucket_list) print("this is estimated_hist2: ", estimated_hist_by_matrix) index = range(bucket_size) plt.plot(index, true_hist) plt.plot(index, estimated_hist) plt.legend(['true', 'krr']) plt.show()
def run_example(): bucket_size = 5 epsilon = 1 print("==========>>>>> in RAPPOR") rappor = RAPPOR(bucket_size=bucket_size, epsilon=epsilon) bucket_list, true_hist = example.generate_bucket( n=10000, bucket_size=bucket_size, distribution_name='uniform') print("this is buckets: ", bucket_list) print("this is true hist: ", true_hist) private_bucket_list = [rappor.user_encode(item) for item in bucket_list] estimate_hist = rappor.aggregate_histogram(private_bucket_list) print("this is estimate_hist", estimate_hist)
def run_example(): bucket_size = 5 epsilon = 1 print("==========>>>>> in KRR") krr = kRR(bucket_size=bucket_size, epsilon=epsilon) bucket_list, true_hist = example.generate_bucket( n=10000, bucket_size=bucket_size, distribution_name='uniform') print("this is buckets: ", bucket_list) print("this is true hist: ", true_hist) private_bucket_list = [krr.encode_item(item) for item in bucket_list] estimate_hist = krr.decode_histogram(private_bucket_list) print("this is estimate_hist", estimate_hist)
def run_example(): bucket_size = 4 epsilon = 1 n = 1000000 # np.random.seed(10) hr = HR(bucket_size=bucket_size, epsilon=epsilon) bucket_list, true_hist = example.generate_bucket( n=n, bucket_size=bucket_size, distribution_name='uniform') print("this is buckets: ", bucket_list) print("this is true hist: ", true_hist) print("==========>>>>> in KRR") private_bucket_list = [hr.encode_item(item) for item in bucket_list] print("this is private buckets: ", private_bucket_list) estimate_hist = hr.decode_histogram(private_bucket_list) print("this is estimate_hist", estimate_hist)
def run_example(): epsilon = 1 n = 10 ** 6 bucket_size = 1000 m = 500000 np.random.seed(10) bucket_list, true_hist = example.generate_bucket(n=n, bucket_size=bucket_size, distribution_name='exp') true_distribution = true_hist / sum(true_hist) print(true_distribution[:10]) example.draw_distribution(true_distribution) SH = SuccinctHistogram(epsilon=epsilon, d=bucket_size, m=m) estimated_hist = SH.PROT_FO(users_data=bucket_list) estimated_distribution = estimated_hist / sum(estimated_hist) example.draw_distribution(estimated_distribution) print(estimated_distribution[:10])
def run_example(): np.set_printoptions(threshold=40, linewidth=200, edgeitems=5) n = 10 ** 5 bucket_size = 100 epsilon = 1 print("==========>>>>> in KRR") krr = GeneralizedRandomizedResponse(bucket_size=bucket_size, epsilon=epsilon) bucket_list, true_hist = example.generate_bucket(n=n, bucket_size=bucket_size, distribution_name='exp') print("this is buckets: ", bucket_list) print("this is true hist: ", true_hist) private_bucket_list = [krr.user_encode(item) for item in bucket_list] estimated_hist = krr.aggregate_histogram(private_bucket_list) print("this is estimate_hist", estimated_hist) index = range(bucket_size) plt.plot(index, true_hist) plt.plot(index, estimated_hist) plt.legend(['true', 'krr']) plt.show()