Question: In [3]: # Load the data and Libraries import pandas as pd import numpy as np from scipy import stats import matplotlib.pyplot as plt
In [3]: # Load the data and Libraries import pandas as pd import numpy as np from scipy import stats import matplotlib.pyplot as plt plt.style.use('seaborn-whitegrid') def laplace_mech (v, sensitivity, epsilon): return v + np.random.laplace(loc=0, scale=sensitivity / epsilon) def laplace_mech_vec(qs, sensitivity, epsilon): return [laplace_mech(q, sensitivity, epsilon) for q in qs] def gaussian_mech(v, sensitivity, epsilon, delta): return v + np.random.normal(loc=0, scale-sensitivity * np.sqrt(2*np.log(1.25/delta)) / epsilon) def gaussian_mech_vec(qs, sensitivity, epsilon, delta): return [gaussian_mech(q, sensitivity, epsilon, delta) for q in qs] def pct_error (orig, priv): return np.abs(orig - priv)/orig * 100.0 adult = pd.read_csv( 'https://github.com/jnear/cs211-data-privacy/raw/master/homework/adult_with_pii.csv') In [ ]: In [ ]: Consider the code below, which defines three average queries and runs them on adult_data, using the Laplace mechanism to provide differential privacy with 1 for each query. b_capgain = 10000 b_age = 3000 epsilon 1 def query1(): return np. sum (adult['Capital Gain'].clip(lower=0, upper=b_capgain)) def query2(): return len(adult[adult['Education-Num'] < 10]) def query3(): return np.sum(adult['Age'].clip (lower=0, upper=b_age)) def my_query(): return [query1(), query2(), query()] my_query() def dp_my_query(epsilon): # YOUR CODE HERE raise Not ImplementedError() dp_my_query(1.0) In 2-5 sentences, answer the following: What is the L global sensitivity of my_query, and why? What is the L2 global sensitivity of my_query, and why? YOUR ANSWER HERE
Step by Step Solution
3.36 Rating (152 Votes )
There are 3 Steps involved in it
The L1 global sensitivity of my query is 10000 3000 10000 53000 This is because the L1 global sensit... View full answer
Get step-by-step solutions from verified subject matter experts
