-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistograms.py
43 lines (36 loc) · 1.15 KB
/
histograms.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
import matplotlib.pyplot as plt
import json
import yaml
import numpy as np
fname="results_object_80v.json"
def k_vs_performance(data):
rel_data = [(float(row[0]),float(row[3]),float(row[7]),float(row[11]))
for row in data.values()]
data_vals = {}
for row in rel_data:
kval,best,gw,naive = row
if kval in data_vals:
data_vals[kval].append((gw/best,naive/best))
else:
data_vals[kval] = [(gw/best,naive/best)]
k = []
gw_vals = []
naive_vals = []
for k_val in data_vals.keys():
k.append(k_val)
gw_vals += [i[0] for i in data_vals[k_val]]
naive_vals += [i[1] for i in data_vals[k_val]]
#fig, ax = plt.subplots()
#plt.hist(gw_vals, 10, facecolor='red')
plt.hist(naive_vals, 10, facecolor='blue')
plt.axis([0.85,0.95,1,15])
plt.ylabel('Number of testcases')
plt.xlabel('approximation')
plt.title('GW Accuracy Distribution for Competition MAX 3-SAT with 80 variables')
plt.show()
def main():
with open(fname) as data_file:
data = yaml.safe_load(data_file)
k_vs_performance(data)
if __name__ == '__main__':
main()