-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_results.py
56 lines (51 loc) · 1.69 KB
/
plot_results.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
import numpy as np
import matplotlib.pyplot as plt
from glob import glob
import os
DIR="./data/"
DIR_FIGS="./figs/"
os.system("mkdir -p "+(DIR_FIGS))
if __name__ == "__main__":
for fname in glob(DIR+"/*.npz"):
print("plot for:",fname)
dic = np.load(fname,allow_pickle=True)["data"]
plt.figure();
# plot ratio
plt.subplot(211)
for curves in dic:
if len(curves["param"]) == 2:
eta,d = curves["param"]
label = "eta = %d, d = %d"%(eta,d)
ylabel = "MI_m/MI_{m+s}"
else:
label = "eta = %d"%(curves["param"][0])
ylabel = "PI/MI"
plt.semilogx(curves["std"]**2,
curves["mi_m"]/curves["mi_ms"],
marker=".",
alpha=.6,
label=label)
plt.grid(True,which="both",ls="--")
plt.xlabel("sigma**2")
plt.ylabel(ylabel)
plt.legend()
# plot information
plt.subplot(212)
for curves in dic:
if len(curves["param"]) == 2:
eta,d = curves["param"]
label = "eta = %d, d = %d"%(eta,d)
else:
label = "eta = %d"%(curves["param"][0])
plt.loglog(curves["std"]**2,
curves["mi_ms"],
marker=".",
alpha=.6,
label=label)
plt.grid(True,which="both",ls="--")
plt.xlabel("sigma**2")
plt.ylabel("Information")
plt.legend()
plt.suptitle(dic[0]["alg"])
plt.savefig(DIR_FIGS+dic[0]["alg"]+".png")
plt.show()