forked from bmcfee/hypergraph_playlist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetBestWorst.py
executable file
·49 lines (37 loc) · 1.14 KB
/
getBestWorst.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
#!/usr/bin/env python
'''
CREATED:2012-03-30 14:10:51 by Brian McFee <[email protected]>
Get the most and least-likely test example playlists per category
Usage:
./getBestWorst.py /path/to/songhash.pickle /path/to/likelihoods.pickle /path/to/playlist/directory
'''
import sys
import cPickle as pickle
import samplePlaylist
import numpy
def getBestWorst(songs, L, plpath):
cats = L.keys()
cats.sort()
for c in cats:
with open('%s/%s_test.pickle' % (plpath, c), 'r') as f:
P = pickle.load(f)
pass
print 'Category: %s' % c
i = numpy.argmax(L[c])
print 'Best playlist: %.4f\n-----------------------' % L[c][i]
samplePlaylist.printPlaylist(P[i], songs)
j = numpy.argmin(L[c])
print 'Worst playlist: %.4f\n-----------------------' % L[c][j]
samplePlaylist.printPlaylist(P[j], songs)
print
pass
pass
if __name__ == '__main__':
with open(sys.argv[1], 'r') as f:
songs = pickle.load(f)
pass
with open(sys.argv[2], 'r') as f:
L = pickle.load(f)
pass
getBestWorst(songs, L['L'], sys.argv[3])
pass