tomwalters@423
|
1 #!/usr/bin/python
|
tomwalters@423
|
2 """
|
tomwalters@423
|
3 plot_munged_results.py
|
tomwalters@423
|
4
|
tomwalters@423
|
5 """
|
tomwalters@423
|
6
|
tom@440
|
7 import matplotlib as mpl
|
tom@440
|
8 mpl.use('PDF')
|
tomwalters@423
|
9 import numpy as np
|
tomwalters@423
|
10 import pylab as p
|
tom@440
|
11 #import matplotlib.pyplot as plt
|
tomwalters@425
|
12
|
tomwalters@423
|
13 f=open("results_test_all.csv","r")
|
tomwalters@423
|
14 results = dict()
|
tomwalters@423
|
15 for line in f:
|
tomwalters@423
|
16 if line[0] != "#":
|
tomwalters@423
|
17 values = line.strip().split(",")
|
tomwalters@423
|
18 results.setdefault(values[3],dict())
|
tomwalters@423
|
19 results[values[3]].setdefault(values[0], dict())
|
tomwalters@423
|
20 results[values[3]][values[0]].setdefault(values[1], dict())
|
tomwalters@424
|
21 results[values[3]][values[0]][values[1]].setdefault(int(values[4]), dict())
|
tomwalters@424
|
22 results[values[3]][values[0]][values[1]][int(values[4])].setdefault(int(values[5]), dict())
|
tomwalters@424
|
23 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])].setdefault(int(values[6]), dict())
|
tomwalters@423
|
24 if values[2] == 'clean':
|
tomwalters@424
|
25 snr = 50
|
tom@440
|
26 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])][int(values[6])][snr] = float(values[7])
|
tomwalters@423
|
27 else:
|
tomwalters@423
|
28 snr = int(values[2])
|
tomwalters@425
|
29 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])][int(values[6])][snr] = float(values[7])
|
tomwalters@423
|
30 # results[values[3]].append((values[1],values[2],values[2],values[4]))
|
tomwalters@423
|
31
|
tom@440
|
32 ax = mpl.pyplot.subplot(111)
|
tomwalters@423
|
33 train_set = 'inner'
|
tom@440
|
34 for hmm_iterations in [2,3,15]:
|
tom@440
|
35 for hmm_states in [3,4]:
|
tom@440
|
36 for hmm_components in [3,4]:
|
tom@440
|
37 lines = []
|
tom@440
|
38 labels = []
|
tom@440
|
39 ax.cla()
|
tom@440
|
40 for feature_type in ('mfcc', 'mfcc_vtln', 'aim'):
|
tom@440
|
41 for feature_subtype in results[train_set][feature_type].keys():
|
tom@440
|
42 try:
|
tom@440
|
43 this_line = results[train_set][feature_type][feature_subtype][hmm_states][hmm_components][hmm_iterations].items()
|
tom@440
|
44 this_line.sort(cmp=lambda x,y: x[0] - y[0])
|
tom@440
|
45 xs, ys = zip(*this_line)
|
tom@440
|
46 xs = list(xs)
|
tom@440
|
47 ys = list(ys)
|
tom@440
|
48 line, = ax.plot(xs,ys,'-o',linewidth=2)
|
tom@440
|
49 lines.append(line)
|
tom@440
|
50 labels.append(feature_type + "_" + feature_subtype)
|
tom@440
|
51 except KeyError:
|
tom@440
|
52 print "Data not found"
|
tom@440
|
53 p.legend(lines, labels, 'upper left', shadow=True)
|
tom@440
|
54 p.xlabel('SNR/dB')
|
tom@440
|
55 p.ylabel('Recognition performance %')
|
tom@440
|
56 output_file = ("recognition_vs_snr_%diterations_%dstates_%d_components.pdf" % (hmm_iterations, hmm_states, hmm_components))
|
tom@440
|
57 p.savefig(output_file) |