-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread_naf_tests.py
97 lines (83 loc) · 2.84 KB
/
read_naf_tests.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import os
import pickle
import sys
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
def read_experiment(root_dir, label = ''):
data_all = pd.DataFrame()
n_average = 25
for root, dirs, files in os.walk(root_dir):
for file in files:
if file == 'plot_data_0.pkl':
file_name = root + os.sep + file
print(file_name)
openfile = open(file_name, 'rb')
data = np.sum(pickle.load(openfile), axis=1)
# data_frame = pd.DataFrame(data, columns=[root.split('/')[0]])
column_names = [root.split('_')[1] + label]
data_frame = pd.DataFrame(data, columns=column_names)
data_frame = data_frame.rolling(n_average).mean().shift(int(n_average / 2))
data_all = pd.concat([data_all, data_frame.T], sort=False)
openfile.close()
return data_all
try:
root_dir = sys.argv[1]
except:
# root_dir = "SINGLE/"
# single = read_experiment(root_dir=root_dir)
# root_dir = "DOUBLE/"
# double = read_experiment(root_dir=root_dir)
# data_all = pd.concat([single, double], sort=False)
root_dir = "Experiments-150-200-50-long/"
data_all = read_experiment(root_dir=root_dir)
# root_dir = "Experiments-150-200-50-long-0.05/"
# data_all_1 = read_experiment(root_dir=root_dir)
root_dir = "Experiments-150-200-50-noisy/"
data_all = read_experiment(root_dir=root_dir)
# data_all = data_all_1
# data_all = pd.concat([data_all, data_all_2])
figure_name = '../Figures/Comparison_noise'
current_test_name = ''
fig, axs = plt.subplots(1, 1, sharex=True)
ax = axs
print(data_all)
sns.set_palette(sns.color_palette("bright", 8))
sns.lineplot(ax=ax, data=data_all.T)
ax.axhline(y=-200, ls=':', c='lime')
plt.ylabel('cum. reward (arb. units.)')
ax.set_ylim(-1250,-100)
print(data_all)
ax.axhline(y=-200, ls=':', c='lime')
ax.legend(['Clipping','No-clipping-no-smoothing','No-clipping-smoothing'])
plt.ylabel('cum. reward (arb. units.)')
plt.xlabel('no. episode')
ax.set_ylim(-1250,-100)
plt.savefig(root_dir + figure_name+'.pdf')
plt.savefig(root_dir + figure_name+'.png')
plt.show()
# fig, axs = plt.subplots(2, 1, sharex=True)
# ax = axs[0]
#
# print(data_all)
#
# sns.set_palette(sns.color_palette("bright", 8))
# sns.lineplot(ax=ax, data=data_all.T)
# ax.axhline(y=-200, ls=':', c='lime')
# plt.ylabel('cum. reward (arb. units.)')
# ax.set_ylim(-1250,-100)
# print(data_all)
#
# root_dir = "Experiments-300-20-large-smoothing/"
# data_all = read_experiment(root_dir=root_dir)
# # sns.set_palette(sns.color_palette("bright", 8))
# ax = axs[1]
# sns.lineplot(ax=ax, data=data_all.T)
# ax.axhline(y=-200, ls=':', c='lime')
#
# plt.ylabel('cum. reward (arb. units.)')
# plt.xlabel('no. episode')
# ax.set_ylim(-1250,-100)
# # plt.savefig(root_dir + figure_name)
# plt.show()