ledmands
commited on
Commit
•
94c3490
1
Parent(s):
acd0718
Began work on plotting improvements between training runs
Browse files
agents/plot_evaluations.py → plot_evaluations.py
RENAMED
File without changes
|
plot_improvement.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
from numpy import load, ndarray
|
3 |
+
|
4 |
+
parser = argparse.ArgumentParser()
|
5 |
+
parser.add_argument("-f", "--filepath", required=True, help="Specify the file path to the agent.", type=str)
|
6 |
+
args = parser.parse_args()
|
7 |
+
|
8 |
+
filepath = args.filepath
|
9 |
+
npdata = load(filepath)
|
10 |
+
|
11 |
+
print(type(npdata['results']))
|
12 |
+
evaluations = ndarray.tolist(npdata['results'])
|
13 |
+
print(type(evaluations))
|
14 |
+
print(len(evaluations))
|
15 |
+
# print(evaluations)
|
16 |
+
sorted_evals = []
|
17 |
+
for eval in evaluations:
|
18 |
+
sorted_evals.append(sorted(eval))
|
19 |
+
|
20 |
+
# Now I have a sorted list.
|
21 |
+
# Now just pop the first and last elements of each eval
|
22 |
+
for eval in sorted_evals:
|
23 |
+
eval.pop(0)
|
24 |
+
eval.pop()
|
25 |
+
|
26 |
+
print()
|
27 |
+
# print(sorted_evals)
|
28 |
+
|
29 |
+
# Now that I have my sorted evaluations, I can calculate the mean episode reward for each eval
|
30 |
+
mean_eval_rewards = []
|
31 |
+
for eval in sorted_evals:
|
32 |
+
mean_eval_rewards.append(sum(eval) / len(eval))
|
33 |
+
|
34 |
+
# Now I should have a list with the mean evaluation reward with the highest and lowest score tossed out
|
35 |
+
print(mean_eval_rewards)
|
36 |
+
print("num evals: " + str(len(mean_eval_rewards)))
|
37 |
+
|
38 |
+
# I'm dealing with a 2D array. Each element contains an array of ten data points
|
39 |
+
# The number of elements is going to vary for each training run
|
40 |
+
# The number of evaluation episodes will be constant, 10.
|
41 |
+
# I need to convert to a regular list first
|
42 |
+
# I could iterate over each element
|