-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting.py
52 lines (45 loc) · 1.74 KB
/
plotting.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
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import math
import scipy.interpolate as ip
def plot_from_file(fname):
data = pd.read_csv(fname, sep=',')
# reward per episode
optimum_reward = 0
plt.plot(data['episode'].values, data['reward'].values,
marker = 'None', linestyle = '-', color = 'b')
plt.axhline(y = optimum_reward, color = 'r', linestyle = '--')
plt.xlabel('episode')
plt.ylabel('reward')
plt.title('Reward Per Episode')
plt.savefig('./plots/reward_per_episode.png', dpi = 500)
plt.close()
# average reward per episode
plt.plot(data['episode'].values, np.divide(data['reward'].values, data['moves'].values),
marker = 'None', linestyle = '-', color = 'b')
plt.xlabel('episode')
plt.ylabel('average reward')
plt.title('Average Reward Per Episode')
plt.savefig('./plots/average_reward_per_episode.png', dpi = 500)
plt.close()
# moves per episode
optimum_moves = 26
plt.plot(data['episode'].values, data['moves'].values,
marker = 'None', linestyle = '-', color = 'b')
plt.axhline(y = optimum_moves, color = 'r', linestyle = '--')
plt.xlabel('episode')
plt.ylabel('moves')
plt.title('Number of Moves Per Episode')
plt.savefig('./plots/moves_per_episode.png', dpi = 500)
plt.close()
# success over time
plt.plot(data['episode'].values, np.cumsum(data['success'].values),
marker = 'None', linestyle = '-', color = 'b')
plt.xlabel('episode')
plt.ylabel('cumulative successes')
plt.title('Cumulative Successes over Time')
plt.savefig('./plots/cumulative_successes.png', dpi = 500)
plt.close()
if __name__ == '__main__':
plot_from_file('./data/practice hill/results_0_1 old.csv')