-
Notifications
You must be signed in to change notification settings - Fork 1
/
combine_evaluation_results.py
54 lines (43 loc) · 1.32 KB
/
combine_evaluation_results.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
43
44
45
46
47
48
49
50
51
52
53
54
import cPickle as pkl
import pandas as pd
import numpy as np
def combine(results):
"""
ronuds of experiment result
results: list<dict<str, pandas.DataFrame>>
"""
metrics = results[0].keys()
combined_result = {}
# reduce
for m in metrics:
acc = np.zeros(results[0][m].as_matrix().shape)
columns = results[0][m].columns
index = results[0][m].index
data3d = []
for r in results:
mat = r[m].as_matrix()
# if mat.shape == (5, 41):
# print "debug!! if you see it, please think if you should remove it"
print mat.shape
data3d.append(mat)
# print(data3d)
mean_val = np.nanmean(np.asarray(data3d), axis=0)
combined_result[m] = pd.DataFrame(
mean_val,
columns=columns,
index=index
)
return combined_result
def main():
import argparse
parser = argparse.ArgumentParser('')
parser.add_argument('--result_paths',
nargs='+')
parser.add_argument('--output_path',
required=True)
args = parser.parse_args()
results = [pkl.load(open(p)) for p in args.result_paths]
pkl.dump(combine(results),
open(args.output_path, 'w'))
if __name__ == '__main__':
main()