annotate experiments/scripts/cnbh-syllables/results_plotting/plot_munged_results.py @ 626:586b0677aae8

Fourth revision of Alex Brandmeyer's C++ implementation. Fixed more style issues, changed AGC structures to vectors, replaced FloatArray2d with vector<FloatArray>, implemented first tests using GTest to verify coefficients and monaural output against Matlab values (stored in aimc/carfac/test_data/). To run tests, change the path stored in carfac_test.h in TEST_SRC_DIR. Added CARFAC_GenerateTestData to the Matlab branch, fixed stage indexing in CARFAC_Cross_Couple.m to reflect changes in AGCCoeffs and AGCState structs.
author alexbrandmeyer
date Wed, 22 May 2013 21:30:02 +0000
parents 988c8b6f7946
children
rev   line source
tomwalters@138 1 #!/usr/bin/python
tomwalters@138 2 """
tomwalters@138 3 plot_munged_results.py
tomwalters@138 4
tomwalters@138 5 """
tomwalters@138 6
tom@253 7 import matplotlib as mpl
tom@253 8 mpl.use('PDF')
tomwalters@138 9 import numpy as np
tomwalters@138 10 import pylab as p
tom@253 11 #import matplotlib.pyplot as plt
tomwalters@251 12
tomwalters@138 13 f=open("results_test_all.csv","r")
tomwalters@138 14 results = dict()
tomwalters@138 15 for line in f:
tomwalters@138 16 if line[0] != "#":
tomwalters@138 17 values = line.strip().split(",")
tomwalters@138 18 results.setdefault(values[3],dict())
tomwalters@138 19 results[values[3]].setdefault(values[0], dict())
tomwalters@138 20 results[values[3]][values[0]].setdefault(values[1], dict())
tomwalters@250 21 results[values[3]][values[0]][values[1]].setdefault(int(values[4]), dict())
tomwalters@250 22 results[values[3]][values[0]][values[1]][int(values[4])].setdefault(int(values[5]), dict())
tomwalters@250 23 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])].setdefault(int(values[6]), dict())
tomwalters@138 24 if values[2] == 'clean':
tomwalters@250 25 snr = 50
tom@253 26 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])][int(values[6])][snr] = float(values[7])
tomwalters@138 27 else:
tomwalters@138 28 snr = int(values[2])
tomwalters@251 29 results[values[3]][values[0]][values[1]][int(values[4])][int(values[5])][int(values[6])][snr] = float(values[7])
tomwalters@138 30 # results[values[3]].append((values[1],values[2],values[2],values[4]))
tomwalters@138 31
tom@253 32 ax = mpl.pyplot.subplot(111)
tomwalters@138 33 train_set = 'inner'
tom@253 34 for hmm_iterations in [2,3,15]:
tom@253 35 for hmm_states in [3,4]:
tom@253 36 for hmm_components in [3,4]:
tom@253 37 lines = []
tom@253 38 labels = []
tom@253 39 ax.cla()
tom@253 40 for feature_type in ('mfcc', 'mfcc_vtln', 'aim'):
tom@253 41 for feature_subtype in results[train_set][feature_type].keys():
tom@253 42 try:
tom@253 43 this_line = results[train_set][feature_type][feature_subtype][hmm_states][hmm_components][hmm_iterations].items()
tom@253 44 this_line.sort(cmp=lambda x,y: x[0] - y[0])
tom@253 45 xs, ys = zip(*this_line)
tom@253 46 xs = list(xs)
tom@253 47 ys = list(ys)
tom@253 48 line, = ax.plot(xs,ys,'-o',linewidth=2)
tom@253 49 lines.append(line)
tom@253 50 labels.append(feature_type + "_" + feature_subtype)
tom@253 51 except KeyError:
tom@253 52 print "Data not found"
tom@253 53 p.legend(lines, labels, 'upper left', shadow=True)
tom@253 54 p.xlabel('SNR/dB')
tom@253 55 p.ylabel('Recognition performance %')
tom@253 56 output_file = ("recognition_vs_snr_%diterations_%dstates_%d_components.pdf" % (hmm_iterations, hmm_states, hmm_components))
tom@253 57 p.savefig(output_file)