-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_swap_threshold.py
83 lines (70 loc) · 2.4 KB
/
plot_swap_threshold.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
76
77
78
79
80
81
82
83
import argparse
import json
import os
import os.path
import numpy as np
import matplotlib.pyplot as plt
from collections import Counter, OrderedDict
database = 'spotify'
operators = ["by_facet", "by_superset",
"by_neighbors", "by_distribution"]
variants = ["IC", "LO", "BL", "HI", "DC"]
thresholds = ["1", "1.5", "2", "2.5", "3", "3.5", "4"]
markers = ["o", "v", "s", "*", "p", "P", "h", "X", "D", "+", 2, 3]
runs_data = {
"top1sum": {
},
}
for variant in variants:
variant_values = []
quality_values = []
for threshold in thresholds:
if threshold == "2":
file_text = ""
else:
file_text = "_"+threshold
if os.path.isfile(f"./runs-data/top1sum/{database}/all/{variant}{file_text}.json"):
with open(f"./runs-data/top1sum/{database}/all/{variant}{file_text}.json") as f:
data = json.load(f)
cumulated_utility = sum([x["utility"] for x in data])
variant_values.append(cumulated_utility)
# quality_values.append(data[-1]["class_score_found_15"])
quality_values.append(data[-1]["found_genre_50"])
runs_data["top1sum"][variant] = {
"utility": variant_values,
"quality":
quality_values
}
figsize = (6, 3.5)
t = thresholds
# UTILITY
# x = np.arange(len(list(processed_data.keys())))
fig = plt.figure(figsize=figsize)
ax = fig.add_subplot()
for key in runs_data["top1sum"].keys():
ax.plot(t, runs_data["top1sum"][key]
["utility"], label=f"Top1Sum_{key}", marker=markers[variants.index(key)])
ax.set_xlabel('SWAP threshold')
ax.set_ylabel('cumulated utility')
ax.legend(loc="upper left", bbox_to_anchor=(1, 1))
# ax.set_title(title)
ax.grid(axis='y', color="gainsboro")
fig.tight_layout()
plt.show()
fig.savefig(
f'graphs/{database}-swap_threshold-top1sum-utility.pdf', bbox_inches='tight')
# SCORE
fig = plt.figure(figsize=figsize)
ax = fig.add_subplot()
for key in runs_data["top1sum"].keys():
ax.plot(t, runs_data["top1sum"][key]
["quality"], label=f"Top1Sum_{key}", marker=markers[variants.index(key)])
ax.set_xlabel('SWAP threshold')
ax.set_ylabel('quality')
ax.legend(loc="upper left", bbox_to_anchor=(1, 1))
# ax.set_title(title)
ax.grid(axis='y', color="gainsboro")
fig.tight_layout()
plt.show()
fig.savefig(
f'graphs/{database}-swap_threshold-top1sum-quality.pdf', bbox_inches='tight')