code: WIP
This commit is contained in:
parent
fbf2c15869
commit
ca85703de8
@ -8,6 +8,8 @@ from datetime import datetime
|
|||||||
from geopy.distance import distance
|
from geopy.distance import distance
|
||||||
import lmdk_bgt
|
import lmdk_bgt
|
||||||
import lmdk_lib
|
import lmdk_lib
|
||||||
|
import lmdk_sel
|
||||||
|
import exp_mech
|
||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
@ -66,33 +68,20 @@ def main(args):
|
|||||||
|
|
||||||
for _ in range(args.iter):
|
for _ in range(args.iter):
|
||||||
|
|
||||||
eps_sel = 0
|
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||||
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]
|
|
||||||
|
|
||||||
# Skip
|
# 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)
|
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_s)
|
||||||
mae_s[i] += lmdk_bgt.mae_cont(rls_data_s)/args.iter
|
mae_s[i] += lmdk_bgt.mae_cont(rls_data_s)/args.iter
|
||||||
|
|
||||||
# Uniform
|
# 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)
|
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_u)
|
||||||
mae_u[i] += lmdk_bgt.mae_cont(rls_data_u)/args.iter
|
mae_u[i] += lmdk_bgt.mae_cont(rls_data_u)/args.iter
|
||||||
|
|
||||||
# Adaptive
|
# 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
|
mae_a[i] += lmdk_bgt.mae_cont(rls_data_a)/args.iter
|
||||||
|
|
||||||
# Calculate once
|
# Calculate once
|
||||||
|
@ -8,6 +8,8 @@ from datetime import datetime
|
|||||||
from geopy.distance import distance
|
from geopy.distance import distance
|
||||||
import lmdk_bgt
|
import lmdk_bgt
|
||||||
import lmdk_lib
|
import lmdk_lib
|
||||||
|
import lmdk_sel
|
||||||
|
import exp_mech
|
||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
@ -62,32 +64,19 @@ def main(args):
|
|||||||
|
|
||||||
for _ in range(args.iter):
|
for _ in range(args.iter):
|
||||||
|
|
||||||
eps_sel = 0
|
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||||
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]
|
|
||||||
|
|
||||||
# Skip
|
# 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)
|
# lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_s)
|
||||||
mae_s[i] += lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter
|
mae_s[i] += lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter
|
||||||
|
|
||||||
# Uniform
|
# 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
|
mae_u[i] += lmdk_bgt.mae_cons(seq, rls_data_u)/args.iter
|
||||||
|
|
||||||
# Adaptive
|
# 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
|
mae_a[i] += lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter
|
||||||
|
|
||||||
# Calculate once
|
# Calculate once
|
||||||
|
@ -7,6 +7,8 @@ from datetime import datetime
|
|||||||
from geopy.distance import distance
|
from geopy.distance import distance
|
||||||
import lmdk_bgt
|
import lmdk_bgt
|
||||||
import lmdk_lib
|
import lmdk_lib
|
||||||
|
import lmdk_sel
|
||||||
|
import exp_mech
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
import time
|
import time
|
||||||
@ -85,31 +87,18 @@ def main(args):
|
|||||||
for bgt in bgt_conf:
|
for bgt in bgt_conf:
|
||||||
for _ in range(args.iter):
|
for _ in range(args.iter):
|
||||||
|
|
||||||
eps_sel = 0
|
lmdks, eps_out = lmdk_sel.find_lmdks(seq, lmdks, bgt['epsilon'])
|
||||||
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]
|
|
||||||
|
|
||||||
# Skip
|
# 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
|
mae_s[i] += lmdk_bgt.mae(seq, rls_data_s)/args.iter
|
||||||
|
|
||||||
# Uniform
|
# 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
|
mae_u[i] += lmdk_bgt.mae(seq, rls_data_u)/args.iter
|
||||||
|
|
||||||
# Adaptive
|
# 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
|
mae_a[i] += lmdk_bgt.mae(seq, rls_data_a)/args.iter
|
||||||
|
|
||||||
# Event
|
# Event
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
from lmdk_lib import *
|
from lmdk_lib import *
|
||||||
|
import exp_mech
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
@ -297,6 +298,23 @@ def get_non_opts_from_bottom(seq, lmdks):
|
|||||||
return non_opts
|
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():
|
def test():
|
||||||
# Start and end points of the sequence
|
# Start and end points of the sequence
|
||||||
# # Nonrandom
|
# # Nonrandom
|
||||||
|
Loading…
Reference in New Issue
Block a user