forked from HarrieO/OnlineLearningToRank
-
Notifications
You must be signed in to change notification settings - Fork 4
/
attacker_avg_summarize.py
75 lines (53 loc) · 1.51 KB
/
attacker_avg_summarize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import matplotlib.pyplot as plt
import json
import sys
DBGD_output = open(sys.argv[1], 'r')
DBGD_output_lines = DBGD_output.readlines()
# Extract macro here
macro = json.loads(DBGD_output_lines[0])
# print(macro)
DBGD_output_lines = DBGD_output_lines[0:]
NDCG_attack = []
NDCG_label = []
iterations = []
lr = []
# graph_title = ""
attack_name = ""
file_name = sys.argv[1]
if "new_freq_attack" in file_name:
attack_name = "new_freq_attack"
elif "freq_attack" in file_name:
attack_name = "freq_attack"
else:
attack_name = "click_kth_doc"
for line in DBGD_output_lines:
run_details = json.loads(line)['simulation_arguments']
# graph_title = run_details['simulation_arguments']['click_models'][0]
Tau = []
num_clicks= []
run_results = json.loads(line)['results']
# print(graph_title)
run_results = json.loads(line)['results']["NDCG_attack"][attack_name]["mean"]
count = 0
for val in run_results:
if count > 0 and (count % 1000 == 0 or count == 9999):
NDCG_attack.append(round(val,5))
# count = 0
count += 1
run_results = json.loads(line)['results']["NDCG_label"][attack_name]["mean"]
count = 0
for val in run_results:
if count % 1000 == 0:
NDCG_label.append(val)
count = 0
count += 1
run_results = json.loads(line)['results']["LR"][attack_name]["mean"]
count = 0
for val in run_results:
if count > 0 and (count % 1000 == 0 or count == 9999):
lr.append(round(val, 6))
# count = 0
count += 1
print("NDCG attack: ", NDCG_attack)
print("NDCG label: ", NDCG_label)
print("LR: ", lr)