-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmpd_stats.py
45 lines (25 loc) · 1.04 KB
/
mpd_stats.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
import argparse
from collections import Counter
import numpy as np
from mpd import load
def main():
parser = argparse.ArgumentParser()
parser.add_argument('jsonfile')
args = parser.parse_args()
playlists = load(args.jsonfile)
print("N =", len(playlists))
lens = [len(p['tracks']) for p in playlists]
print("Playlist track count:", Counter(lens))
has_playlist = ['name' in p for p in playlists]
print("Has playlist name:", Counter(has_playlist))
nameless_lens = [len(p['tracks']) for p in playlists if 'name' not in p]
print("Playlist track count among nameless:", Counter(nameless_lens))
named_lens = [len(p['tracks']) for p in playlists if 'name' in p]
print("Playlist track count among nameless:", Counter(named_lens))
try:
holdouts = np.array([p['num_holdouts'] for p in playlists])
print("Holdouts: {:.2f} {:.2f}".format(holdouts.mean(), holdouts.std()))
except KeyError:
print("[warn] Num holdouts property missing")
if __name__ == '__main__':
main()