lmdk_bgt: Added Skip
This commit is contained in:
parent
5afaa055b3
commit
1a464d2fb8
@ -374,6 +374,36 @@ def skip(seq, lmdks, epsilon):
|
|||||||
return rls_data, bgts
|
return rls_data, bgts
|
||||||
|
|
||||||
|
|
||||||
|
def skip_cont(seq, lmdks, epsilon):
|
||||||
|
'''
|
||||||
|
Skip landmarks.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
seq - The point sequence.
|
||||||
|
lmdks - The landmarks.
|
||||||
|
epsilon - The available privacy budget.
|
||||||
|
Returns:
|
||||||
|
rls_data - The perturbed data.
|
||||||
|
bgts - The privacy budget allocation.
|
||||||
|
'''
|
||||||
|
# Event-level budget allocation
|
||||||
|
bgts = np.array(len(seq)*[epsilon])
|
||||||
|
# Released
|
||||||
|
rls_data = [None]*len(seq)
|
||||||
|
for i, p in enumerate(seq):
|
||||||
|
# Check if current point is a landmark
|
||||||
|
r = p[2] in lmdks
|
||||||
|
# Add noise
|
||||||
|
o = lmdk_lib.randomized_response(r, bgts[i])
|
||||||
|
if r:
|
||||||
|
if i > 0:
|
||||||
|
# Approximate with previous
|
||||||
|
o = rls_data[i - 1][1]
|
||||||
|
bgts[i] = 0
|
||||||
|
rls_data[i] = [r, o]
|
||||||
|
return rls_data, bgts
|
||||||
|
|
||||||
|
|
||||||
def sample(seq, lmdks, epsilon):
|
def sample(seq, lmdks, epsilon):
|
||||||
'''
|
'''
|
||||||
Publish randomly.
|
Publish randomly.
|
||||||
@ -602,5 +632,4 @@ def mae_cont(o):
|
|||||||
# Check if original differs from final
|
# Check if original differs from final
|
||||||
if p[0] != p[1]:
|
if p[0] != p[1]:
|
||||||
mae += 1/len(o)
|
mae += 1/len(o)
|
||||||
print(mae)
|
|
||||||
return mae
|
return mae
|
||||||
|
Loading…
Reference in New Issue
Block a user