-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.py
36 lines (29 loc) · 961 Bytes
/
plotter.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
import matplotlib.pyplot as plt
from IPython import display
plt.ion()
class Plotter:
def __init__(self):
self.scores = []
self.mean_scores = []
self.n_updates = 0
self.total = 0
def add_score(self, score):
self.n_updates += 1
self.total += score
mean_score = self.total / self.n_updates
self.scores.append(score)
self.mean_scores.append(mean_score)
def plot(self):
display.clear_output(wait=True)
display.display(plt.gcf())
plt.clf()
plt.title('Training...')
plt.xlabel('Number of Games')
plt.ylabel('Score')
plt.plot(self.scores)
plt.plot(self.mean_scores)
plt.ylim(ymin=0)
plt.text(len(self.scores)-1, self.scores[-1], str(self.scores[-1]))
plt.text(len(self.mean_scores)-1, self.mean_scores[-1], str(self.mean_scores[-1]))
plt.show(block=False)
plt.pause(.1)