-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_scores.py
34 lines (23 loc) · 900 Bytes
/
plot_scores.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
import pandas as pd
import matplotlib.pyplot as plt
location = 'ppo_9_stats'
for location in ['models/ppo_8_stats','models/ppo_9_stats']:
with open(f'{location}/scores.csv', 'r', encoding='utf-8') as file:
lines = file.read().split('\n')[:-1]
scores = [int(line) for line in lines]
window_size = 1000
# Convert array of integers to pandas series
numbers_series = pd.Series(scores)
# Get the window of series
# of observations of specified window size
windows = numbers_series.rolling(window_size)
# Create a series of moving
# averages of each window
moving_averages = windows.mean()
moving_averages.plot(kind = 'line')
plt.show()
# # Convert pandas series back to list
# moving_averages_list = moving_averages.tolist()
# # Remove null entries from the list
# final_list = moving_averages_list[window_size - 1:]
# print(final_list)