-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateGraphs.py
42 lines (39 loc) · 937 Bytes
/
generateGraphs.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
from os.path import exists
import numpy as np
import torch
import random
from matplotlib import pylab
import serial
import time
import struct # for sending data as bytes
import csv
from itertools import chain
from functools import reduce
file = open('RunningRewards.csv')
data = list(csv.reader(file))
file.close()
newList = []
runningAve = 0
finalAveList = []
for a in data:
for b in a:
newList.append(int(b))
for i in range(len(newList)):
runningAve += newList[i]
if (i+1) % 10 == 0:
finalAveList.append(runningAve/10.0)
runningAve = 0
print(newList)
print(finalAveList)
'''
pylab.xlabel('Episode')
pylab.ylabel('Duration')
pylab.title('Episode Duration')
pylab.plot(newList)
pylab.savefig("RewardsGraph.pdf", format="pdf")
'''
pylab.xlabel('Episodes / 10')
pylab.ylabel('Duration')
pylab.title('Episode Duration')
pylab.plot(finalAveList)
pylab.savefig("RewardsGraphAveraged.pdf", format="pdf")