-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_generation.py
46 lines (35 loc) · 1.14 KB
/
plot_generation.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
import os
import argparse
import pandas as pd
import matplotlib.pyplot as plt
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Plotting argparser')
parser.add_argument('--mode', type=int, help='Blackjack mode', required=True)
parser.add_argument('--version', '-v', type=str, help='Model version', required=True)
args = parser.parse_args()
MODE = args.mode
VERSION = args.version
LOG_PATH = f'reward_logs/rewards_{VERSION}_{MODE}.txt'
if not os.path.isfile(LOG_PATH):
print(f'Version and mode combination does not exist.')
exit(0)
df = pd.read_csv(LOG_PATH, header=None, delimiter=',')
titles = {
1: "Basic",
2: "Regular",
3: "All the 2's",
4: "Random"
}
print(df.iloc[:,1])
print(df.iloc[0,1][:-1])
f = lambda x: float(x[:-1])
vals = df.iloc[:,1].apply(f)
print(vals.shape)
print(vals.head())
plt.plot(vals)
plt.xlabel("Episodes")
plt.ylabel("Mean Reward")
plt.title(f'{titles[MODE]}')
plt.ylim((0,1))
plt.savefig(f'./plots/{VERSION}_{MODE}.png')
#plt.show()