-
Notifications
You must be signed in to change notification settings - Fork 0
/
rew_plot.py
150 lines (140 loc) · 6.72 KB
/
rew_plot.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import numpy as np
import csv
import seaborn as sns
import pandas as pd
from itertools import chain
import matplotlib.pyplot as plt
data1 = {"rewards":[], "Episodes x 10":[], "type":[]}
num_episodes = 5000
seed_start = 0
seed_end = 8
explorer = 'revd'
window = 20
# listOfMasses = [0.05,0.1,0.15,0.2,0.25,0.3, 0.35, 0.4, 0.45, 0.5]
# masses = [0.1,0.2,0.3, 0.4, 0.5]
# sizes = [0.015,0.065]
# a = list(chain.from_iterable([[(masses[i],sizes[j]) for i in range(len(masses))] for j in range(len(sizes))]))
# for item in a:
# games_df = pd.read_csv(f'/lab/ssontakk/CausalWorld/tutorials/stable_baselines/stacking3Gen/{item[0]}_{item[1]}.monitor.csv', skiprows=2, header = None)
# # sumRew = []
# for j in range(4000):
# data1["rewards"].append(games_df[0].iloc[j])
# data1["t"].append(j)
# data1["type"].append("Generalist")
# # # rewards.append(sumRew)
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/revd/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"revd_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/rise/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"rise_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/ride/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"ride_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/rnd/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"rnd_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/re3/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"re3_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/saliency/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"saliency_joint")
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/{explorer}/turtlebot_nav/ppo/joint/0.monitor.csv', skiprows=1, header = 0)
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/{explorer}/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# # data1["rewards_roll"].append(games_df[0].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"{explorer}_joint")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/{explorer}/turtlebot_nav/ppo/joint/with_saliency/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"{explorer}_joint_with_saliency")
for i in range(seed_start,seed_end):
games_df = pd.read_csv(f'/lab/ssontakk/tgambhir/heirarchyModels/dmc_place_cradle_features/slidingWindow/logs_ht_1000000_bt_100000/{i}.monitor.csv', skiprows=1, header = 0)
games_df['r'] = games_df['r'].rolling(window=window).mean()
# sumRew = []
for j in range(num_episodes):
print(i,j)
data1["rewards"].append(games_df['r'].iloc[j])
data1["Episodes x 10"].append(j)
data1["type"].append(f"ours")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/re3/multitask_pretrain/turtlebot_nav/ppo/task_rew_True_curiosity_True_saliency_True/finetuned_turtlebot_nav_Pomaria_1_int/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"Saliency")
# for i in range(seed_start,seed_end):
# games_df = pd.read_csv(f'/lab/ssontakk/rl-exploration-baselines/examples/logs/tr_0_collision/turtlebot_nav/ppo/joint/{i}.monitor.csv', skiprows=1, header = 0)
# games_df['r'] = games_df['r'].rolling(window=window).mean()
# # sumRew = []
# for j in range(num_episodes):
# print(i,j)
# data1["rewards"].append(games_df['r'].iloc[j])
# data1["Episodes x 10"].append(j)
# data1["type"].append(f"tabula rasa no collision penalty")
sns.set_theme(style="darkgrid")
sns_plot = sns.lineplot(data=data1,x="Episodes x 10",y="rewards",hue="type")
# plt.legend(loc='lower right', borderaxespad=0)
# # plt.ylim(-5, 10)
# # sns_plot.set(xscale="log")
# # sns_plot = sns.lineplot(data=data,x="t",y="rewards")
sns_plot.figure.savefig(f"ours.png")
# sns_plot.figure.savefig("PPO-Ihlen_0_int-TR.png")
# print(games_df)