code: WIP
This commit is contained in:
parent
fbf2c15869
commit
ca85703de8
@ -8,6 +8,8 @@ from datetime import datetime
|
||||
from geopy.distance import distance
|
||||
import lmdk_bgt
|
||||
import lmdk_lib
|
||||
import lmdk_sel
|
||||
import exp_mech
|
||||
import math
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
@ -66,33 +68,20 @@ def main(args):
|
||||
|
||||
for _ in range(args.iter):
|
||||
|
||||
eps_sel = 0
|
||||
if pct != 0 and pct != 100:
|
||||
# Get landmarks timestamps in sequence
|
||||
lmdks_seq = lmdk_lib.find_lmdks_seq(seq, lmdks)
|
||||
# Turn landmarks to histogram
|
||||
hist, h = lmdk_lib.get_hist(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Find all possible options
|
||||
opts = lmdk_sel.get_opts_from_top_h(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Landmarks selection budget
|
||||
eps_sel = epsilon/(len(lmdks_seq) + 1)
|
||||
# Get private landmarks timestamps
|
||||
lmdks_seq, _ = exp_mech.exponential_pareto(hist, opts, exp_mech.score, 1.0, eps_sel)
|
||||
# Get actual landmarks values
|
||||
lmdks = seq[lmdks_seq]
|
||||
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||
|
||||
# Skip
|
||||
rls_data_s, bgts_s = lmdk_bgt.skip_cont(seq, lmdks, epsilon - eps_sel)
|
||||
rls_data_s, bgts_s = lmdk_bgt.skip_cont(seq, lmdks, eps_out)
|
||||
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_s)
|
||||
mae_s[i] += lmdk_bgt.mae_cont(rls_data_s)/args.iter
|
||||
|
||||
# Uniform
|
||||
rls_data_u, bgts_u = lmdk_bgt.uniform_cont(seq, lmdks, epsilon - eps_sel)
|
||||
rls_data_u, bgts_u = lmdk_bgt.uniform_cont(seq, lmdks, eps_out)
|
||||
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_u)
|
||||
mae_u[i] += lmdk_bgt.mae_cont(rls_data_u)/args.iter
|
||||
|
||||
# Adaptive
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks, epsilon - eps_sel, .5, .5)
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks, eps_out, .5, .5)
|
||||
mae_a[i] += lmdk_bgt.mae_cont(rls_data_a)/args.iter
|
||||
|
||||
# Calculate once
|
||||
|
@ -8,6 +8,8 @@ from datetime import datetime
|
||||
from geopy.distance import distance
|
||||
import lmdk_bgt
|
||||
import lmdk_lib
|
||||
import lmdk_sel
|
||||
import exp_mech
|
||||
import math
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
@ -62,32 +64,19 @@ def main(args):
|
||||
|
||||
for _ in range(args.iter):
|
||||
|
||||
eps_sel = 0
|
||||
if pct != 0 and pct != 100:
|
||||
# Get landmarks timestamps in sequence
|
||||
lmdks_seq = lmdk_lib.find_lmdks_seq(seq, lmdks)
|
||||
# Turn landmarks to histogram
|
||||
hist, h = lmdk_lib.get_hist(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Find all possible options
|
||||
opts = lmdk_sel.get_opts_from_top_h(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Landmarks selection budget
|
||||
eps_sel = epsilon/(len(lmdks_seq) + 1)
|
||||
# Get private landmarks timestamps
|
||||
lmdks_seq, _ = exp_mech.exponential_pareto(hist, opts, exp_mech.score, 1.0, eps_sel)
|
||||
# Get actual landmarks values
|
||||
lmdks = seq[lmdks_seq]
|
||||
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||
|
||||
# Skip
|
||||
rls_data_s, bgts_s = lmdk_bgt.skip_cons(seq, lmdks, epsilon - eps_sel)
|
||||
rls_data_s, bgts_s = lmdk_bgt.skip_cons(seq, lmdks, eps_out)
|
||||
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_s)
|
||||
mae_s[i] += lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter
|
||||
|
||||
# Uniform
|
||||
rls_data_u, bgts_u = lmdk_bgt.uniform_cons(seq, lmdks, epsilon - eps_sel)
|
||||
rls_data_u, bgts_u = lmdk_bgt.uniform_cons(seq, lmdks, eps_out)
|
||||
mae_u[i] += lmdk_bgt.mae_cons(seq, rls_data_u)/args.iter
|
||||
|
||||
# Adaptive
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks, epsilon - eps_sel, .5, .5)
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks, eps_out, .5, .5)
|
||||
mae_a[i] += lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter
|
||||
|
||||
# Calculate once
|
||||
|
@ -7,6 +7,8 @@ from datetime import datetime
|
||||
from geopy.distance import distance
|
||||
import lmdk_bgt
|
||||
import lmdk_lib
|
||||
import lmdk_sel
|
||||
import exp_mech
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
import time
|
||||
@ -85,31 +87,18 @@ def main(args):
|
||||
for bgt in bgt_conf:
|
||||
for _ in range(args.iter):
|
||||
|
||||
eps_sel = 0
|
||||
if lmdk != 0 and lmdk != 100:
|
||||
# Get landmarks timestamps in sequence
|
||||
lmdks_seq = lmdk_lib.find_lmdks_seq(seq, lmdks)
|
||||
# Turn landmarks to histogram
|
||||
hist, h = lmdk_lib.get_hist(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Find all possible options
|
||||
opts = lmdk_sel.get_opts_from_top_h(lmdk_lib.get_seq(1, len(seq)), lmdks_seq)
|
||||
# Landmarks selection budget
|
||||
eps_sel = bgt['epsilon']/(len(lmdks_seq) + 1)
|
||||
# Get private landmarks timestamps
|
||||
lmdks_seq, _ = exp_mech.exponential_pareto(hist, opts, exp_mech.score, 1.0, eps_sel)
|
||||
# Get actual landmarks values
|
||||
lmdks = seq[lmdks_seq]
|
||||
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, bgt['epsilon'])
|
||||
|
||||
# Skip
|
||||
rls_data_s, _ = lmdk_bgt.skip(seq, lmdks, bgt['epsilon'] - eps_sel)
|
||||
rls_data_s, _ = lmdk_bgt.skip(seq, lmdks, eps_out)
|
||||
mae_s[i] += lmdk_bgt.mae(seq, rls_data_s)/args.iter
|
||||
|
||||
# Uniform
|
||||
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks, bgt['epsilon'] - eps_sel)
|
||||
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks, eps_out)
|
||||
mae_u[i] += lmdk_bgt.mae(seq, rls_data_u)/args.iter
|
||||
|
||||
# Adaptive
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks, bgt['epsilon'] - eps_sel, .5, .5)
|
||||
rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks, eps_out, .5, .5)
|
||||
mae_a[i] += lmdk_bgt.mae(seq, rls_data_a)/args.iter
|
||||
|
||||
# Event
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import itertools
|
||||
from lmdk_lib import *
|
||||
import exp_mech
|
||||
import numpy as np
|
||||
import random
|
||||
import time
|
||||
@ -297,6 +298,23 @@ def get_non_opts_from_bottom(seq, lmdks):
|
||||
return non_opts
|
||||
|
||||
|
||||
def find_lmdks(seq, lmdks, epsilon):
|
||||
eps_sel = 0
|
||||
if len(lmdks) > 0 and len(seq) != len(lmdks):
|
||||
# Get landmarks timestamps in sequence
|
||||
lmdks_seq = find_lmdks_seq(seq, lmdks)
|
||||
# Turn landmarks to histogram
|
||||
hist, h = get_hist(get_seq(1, len(seq)), lmdks_seq)
|
||||
# Find all possible options
|
||||
opts = get_opts_from_top_h(get_seq(1, len(seq)), lmdks_seq)
|
||||
# Landmarks selection budget
|
||||
eps_sel = epsilon/(len(lmdks_seq) + 1)
|
||||
# Get private landmarks timestamps
|
||||
lmdks_seq, _ = exp_mech.exponential_pareto(hist, opts, exp_mech.score, 1.0, eps_sel)
|
||||
# Get actual landmarks values
|
||||
lmdks = seq[lmdks_seq]
|
||||
return lmdks, epsilon - eps_sel
|
||||
|
||||
def test():
|
||||
# Start and end points of the sequence
|
||||
# # Nonrandom
|
||||
|
Loading…
Reference in New Issue
Block a user