File size: 1,339 Bytes
94c3490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import argparse
from numpy import load, ndarray

parser = argparse.ArgumentParser()
parser.add_argument("-f", "--filepath", required=True, help="Specify the file path to the agent.", type=str)
args = parser.parse_args()

filepath = args.filepath
npdata = load(filepath)

print(type(npdata['results']))
evaluations = ndarray.tolist(npdata['results'])
print(type(evaluations))
print(len(evaluations))
# print(evaluations)
sorted_evals = []
for eval in evaluations:
    sorted_evals.append(sorted(eval))

# Now I have a sorted list.
# Now just pop the first and last elements of each eval
for eval in sorted_evals:
    eval.pop(0)
    eval.pop()

print()
# print(sorted_evals)

# Now that I have my sorted evaluations, I can calculate the mean episode reward for each eval
mean_eval_rewards = []
for eval in sorted_evals:
    mean_eval_rewards.append(sum(eval) / len(eval))
    
# Now I should have a list with the mean evaluation reward with the highest and lowest score tossed out
print(mean_eval_rewards)
print("num evals: " + str(len(mean_eval_rewards)))

# I'm dealing with a 2D array. Each element contains an array of ten data points
# The number of elements is going to vary for each training run
# The number of evaluation episodes will be constant, 10.
# I need to convert to a regular list first
# I could iterate over each element