forked from hardmaru/slimevolleygym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
49 lines (47 loc) · 1.3 KB
/
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
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import argparse
import pickle
'''
parser = argparse.ArgumentParser(description='')
parser.add_argument('--path', type=str)
args = parser.parse_args()
LOG_DIR = [args.path]
'''
'''
plt.figure()
for folder in LOG_DIR:
log = pd.read_csv('/'.join([folder, 'progress.csv']))
try:
plt.plot(log['total_timesteps'], log['ep_reward_mean'], label=folder)
except:
plt.plot(log['TimestepsSoFar'], log['EpRewMean'], label=folder)
plt.xlabel('training time steps')
plt.ylabel('reward mean')
plt.savefig(folder + '/reward_train.png')
plt.close()
'''
'''
plt.figure()
for folder in LOG_DIR:
eval_result = np.load('/'.join([folder, 'evaluations.npz']))
eval_mean_reward = eval_result['results'].mean(axis=1).ravel()
plt.plot(eval_mean_reward, label=folder)
plt.xlabel('evaluation round')
plt.ylabel('reward mean')
plt.savefig(folder + '/reward_eval.png')
plt.close()
'''
labels = ['random_origin', 'random_new', 'latest_origin', 'latest_new']
opponent = 'ppo'
plt.figure()
for label in labels:
with open('eval_%s_against_%s.pkl' %(label, opponent), 'rb') as f:
evaluation_curve = pickle.load(f)
plt.plot([x[0] for x in evaluation_curve], label=label)
plt.legend()
plt.savefig('eval_against_%s.png' %(opponent))
plt.close()