def t_test(name): # if name == 'c20ng': # return dresults = experiment.read_csv(experiment.csv_path(name, "dag", "compare")) tresults = experiment.read_csv(experiment.csv_path(name, "tree", "compare")) dtst = [float(r["tst_llh"]) for r in dresults] ttst = [float(r["tst_llh"]) for r in tresults] dsize = [int(r["num_nodes"]) for r in dresults] tsize = [int(r["num_nodes"]) for r in tresults] dtime = [float(r["time"]) for r in dresults] ttime = [float(r["time"]) for r in tresults] print (name + " ")[:8], "\t%.4f" % np.mean(dtst), "\t%.4f" % np.mean(ttst), "\t", np.mean(dtst) > np.mean( ttst ), "\t\t", "%6d" % int(np.mean(dsize)), "%7d" % int(np.mean(tsize)), "\t", "%.4f" % ( np.mean(dsize) / np.mean(tsize) ), "\t%8.2f" % np.mean( dtime ), " %8.2f" % np.mean( ttime ), np.mean( dtime ) / np.mean( ttime ), from scipy import stats print "\t", stats.ttest_ind(dtst, ttst, equal_var=False)[1] < 0.05
def best_grid_point(name, structure, dirname): bp = experiment.csv_path(name, structure, dirname) rows = experiment.read_csv(bp) return best_row(rows)
def main(): name = 'Aly & Fila - Future Sound of Egypt 338 ' print name csv_file = os.path.join('.', 'data', name + experiment.plugin_suffix + '.csv') cue_file = os.path.join('.', 'data', name + '.cue') sim_file = os.path.join('.', 'data', name + experiment.plugin_suffix + '.sim') timestamps, data = experiment.read_csv(csv_file) info = experiment.read_cue(cue_file) has_intro = 'intro' in info[0]['TITLE'].strip().lower() has_outro = 'outro' in info[-1]['TITLE'].strip().lower() with open(sim_file, 'rb') as f: (self_sim, factor) = cPickle.load(f) filtered, novelty = tools.init_borders2(self_sim) sec_per_row = timestamps[-1] / self_sim.shape[0] #filtered = [x * sec_per_row for x in filtered] filtered = tools.detect_track_borders(data, timestamps[-1], len(info), self_sim=self_sim, factor=factor, has_intro=has_intro, has_outro=has_outro) #make_average(data, factor, [int(x / sec_per_row) for x in filtered]) #for i in range(len(info)): # print '%d.\t%.2f\t%.2f: %f' % (i, info[i]['INDEX'], filtered[i], filtered[i] - info[i]['INDEX']) #print filtered #print [x['INDEX'] for x in info] #print experiment.get_diff(info, filtered) data = data.transpose((1, 0)) draw_spectrum(data, timestamps, 1) #draw_selfsim(self_sim, timestamps) vlines([datetime.datetime.fromtimestamp(x) for x in filtered], 0, 24, color='k', linewidths=[1] * len(filtered), alpha=1.0) vlines([datetime.datetime.fromtimestamp(x['INDEX']) for x in info], 24, 48, color='y', linewidths=[1] * len(info), alpha=1.0) #savefig('fig.pdf', bbox_inches='tight') tracks = [(x['PERFORMER'], x['TITLE']) for x in info] export_cue(name, tracks, filtered) # borders2, novelty = tools.init_borders2(self_sim) # plt.figure(2) # plt.plot(novelty) # print borders2 #draw_spectrum(data2, timestamps, 2) # plt.figure(2) # plt.plot(data2) # plt.figure(3) # plt.matshow(areas, fignum=3) # _, axs = plt.subplots(5, 1, sharex=True) # tss = [datetime.datetime.fromtimestamp(x) for x in timestamps] # for i in range(len(centroids)): # axs[i].plot(centroids[i]) # axs[4].plot(flux) # plt.figure(4) # plt.matshow(self_sim, fignum=4) show()
def main(): name = 'Aly & Fila - Future Sound of Egypt 338 ' print name csv_file = os.path.join('.', 'data', name + experiment.plugin_suffix + '.csv') cue_file = os.path.join('.', 'data', name + '.cue') sim_file = os.path.join('.', 'data', name + experiment.plugin_suffix + '.sim') timestamps, data = experiment.read_csv(csv_file) info = experiment.read_cue(cue_file) has_intro = 'intro' in info[0]['TITLE'].strip().lower() has_outro = 'outro' in info[-1]['TITLE'].strip().lower() with open(sim_file, 'rb') as f: (self_sim, factor) = cPickle.load(f) filtered, novelty = tools.init_borders2(self_sim) sec_per_row = timestamps[-1] / self_sim.shape[0] #filtered = [x * sec_per_row for x in filtered] filtered = tools.detect_track_borders(data, timestamps[-1], len(info), self_sim=self_sim, factor=factor, has_intro=has_intro, has_outro=has_outro) #make_average(data, factor, [int(x / sec_per_row) for x in filtered]) #for i in range(len(info)): # print '%d.\t%.2f\t%.2f: %f' % (i, info[i]['INDEX'], filtered[i], filtered[i] - info[i]['INDEX']) #print filtered #print [x['INDEX'] for x in info] #print experiment.get_diff(info, filtered) data = data.transpose((1, 0)) draw_spectrum(data, timestamps, 1) #draw_selfsim(self_sim, timestamps) vlines([datetime.datetime.fromtimestamp(x) for x in filtered], 0, 24, color='k', linewidths=[1]*len(filtered), alpha=1.0) vlines([datetime.datetime.fromtimestamp(x['INDEX']) for x in info], 24, 48, color='y', linewidths=[1]*len(info), alpha=1.0) #savefig('fig.pdf', bbox_inches='tight') tracks = [(x['PERFORMER'], x['TITLE']) for x in info] export_cue(name, tracks, filtered) # borders2, novelty = tools.init_borders2(self_sim) # plt.figure(2) # plt.plot(novelty) # print borders2 #draw_spectrum(data2, timestamps, 2) # plt.figure(2) # plt.plot(data2) # plt.figure(3) # plt.matshow(areas, fignum=3) # _, axs = plt.subplots(5, 1, sharex=True) # tss = [datetime.datetime.fromtimestamp(x) for x in timestamps] # for i in range(len(centroids)): # axs[i].plot(centroids[i]) # axs[4].plot(flux) # plt.figure(4) # plt.matshow(self_sim, fignum=4) show()