comparison trunk/experiments/scripts/cnbh-syllables/results_plotting/plot_munged_results.py @ 440:99f9bf0f7798

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