-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload_graphs.py
More file actions
36 lines (29 loc) · 1.24 KB
/
load_graphs.py
File metadata and controls
36 lines (29 loc) · 1.24 KB
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
import pandas as pd
import matplotlib.pyplot as plt
parent = 'data/'
task = 'vanillaSAC_microwave_data/'
graph = parent + task + 'reward/'
data_file_1 = graph + 'runs_2024-12-04_16-39-00_vanillaSAC_dataLoaded_train_phase_1_microwave.csv'
# data_file_2 = graph + 'runs_2024-11-30_11-59-00_live_train_phase_2_hinge_cabinet.csv'
# data_file_3 = graph + 'runs_2024-11-30_12-49-14_live_train_phase_3_hinge_cabinet.csv'
df_1 = pd.read_csv(data_file_1)
# df_2 = pd.read_csv(data_file_2)
# df_3 = pd.read_csv(data_file_3)
def exponential_moving_average(data, alpha=0.3):
return data.ewm(alpha=alpha).mean()
# Apply EMA
df_1['Smoothed_Value'] = exponential_moving_average(df_1['Value'])
# df_2['Smoothed_Value'] = exponential_moving_average(df_2['Value'])
# df_3['Smoothed_Value'] = exponential_moving_average(df_3['Value'])
# Plot the smoothed data
plt.plot(df_1['Step'], df_1['Smoothed_Value'], label='phase 1')
# plt.plot(df_2['Step'], df_2['Smoothed_Value'], label='phase 2')
# plt.plot(df_3['Step'], df_3['Smoothed_Value'], label='phase 3')
# Plot details
plt.xlabel('Step')
plt.ylabel('Value')
plt.suptitle('Microwave (Vanilla SAC with pre-populated replay buffer)')
plt.title('reward')
plt.legend()
plt.savefig("graphs/"+graph.replace("/","_"))
plt.show()