forked from bmcfee/hypergraph_playlist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresultsToMat.py
More file actions
executable file
·46 lines (31 loc) · 869 Bytes
/
resultsToMat.py
File metadata and controls
executable file
·46 lines (31 loc) · 869 Bytes
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
#!/usr/bin/env python
'''
CREATED:2012-04-02 17:50:05 by Brian McFee <bmcfee@cs.ucsd.edu>
Convert performance metrics into .mat format
Only stores the scores
Usage:
./resultsToMat.py perf.pickle results_out.mat
'''
import cPickle as pickle
import numpy
import scipy.io
import sys
def convert(inpickle, outmat):
with open(inpickle, 'r') as f:
P = pickle.load(f)['scores']
pass
labels = P.keys()
labels.sort()
n = len(labels)
m = len(P[labels[0]][labels[0]])
Xall = numpy.zeros((n,m))
Xspec = numpy.zeros((n,m))
for (i, l) in enumerate(labels):
Xall[i] = P['ALL'][l]
Xspec[i] = P[l][l]
pass
scipy.io.savemat(outmat, {'labels': labels, 'Xall': Xall, 'Xspec': Xspec}, oned_as='column')
pass
if __name__ == '__main__':
convert(sys.argv[1], sys.argv[2])
pass