def subgraph_perdb(noise): lengths = ["8", "15", "30"] levels = ["10", "20", "30"] fp = ["echoprint", "chromaprint", "landmark"] linestyle = ["-", ":", "--"] x = [8, 15, 30] pointstyle = ["o", "^", "+"] plt.figure() plt.xlim([5, 55]) plt.xlabel("Query length (seconds)") plt.xticks(x) plt.ylabel("Accuracy") plt.ylim([0.0, 1.0]) plt.title("Accuracy with added %s noise" % noise) count = 1 for p, lev in zip(pointstyle, levels): plt.subplot(3, 1, count) dbel = 10 - int(lev) plt.xlim([5, 45]) plt.xlabel("Query length (seconds)") plt.xticks(x) plt.ylabel("Accuracy") plt.ylim([0.0, 1.0]) plt.title("Accuracy with %ddB %s noise" % ( dbel, noise, )) count += 1 print "noise", lev for line, c in zip(linestyle, fp): print " fp", c data = [] for lng in lengths: print ".", sys.stdout.flush() munge = "%s%s,chop%s" % (noise, lev, lng) row = db.session.query( evaluation.Run).filter(evaluation.Run.engine == c).filter( evaluation.Run.munge == munge).one() i = row.id s = stats.stats(i) accuracy = stats.prf(s)["accuracy"] data.append(accuracy) print "" linefmt = "k%s%s" % (line, p) lab = "%s" % (c, ) plt.plot(x, data, linefmt, label=lab) plt.legend() plt.savefig("plot-%s-perdb.png" % noise)
def subgraph_perfp(noise): lengths = ["8", "15", "30"] levels = ["10", "20", "30"] fp = ["echoprint", "chromaprint", "landmark"] linestyle = ["-", ":", "--"] x = [8, 15, 30] pointstyle = ["o", "^", "+"] plt.figure() plt.xlim([5, 55]) plt.xlabel("Query length (seconds)") plt.xticks(x) plt.ylabel("Accuracy") plt.ylim([0.0, 1.0]) plt.title("Accuracy with added %s noise" % noise) count = 1 for line, c in zip(linestyle, fp): plt.subplot(3, 1, count) plt.xlim([5, 45]) plt.xlabel("Query length (seconds)") plt.xticks(x) plt.ylabel("Accuracy") plt.ylim([0.0, 1.0]) plt.title("%s accuracy with added %s noise" % (c, noise)) count += 1 print "fp", c for p, lev in zip(pointstyle, levels): print " noise", lev data = [] for lng in lengths: print ".", sys.stdout.flush() munge = "%s%s,chop%s" % (noise, lev, lng) row = db.session.query(evaluation.Run).filter(evaluation.Run.engine==c).filter(evaluation.Run.munge==munge).one() i = row.id s = stats.stats(i) accuracy = stats.prf(s)["accuracy"] data.append(accuracy) print "" linefmt = "k%s%s" % (line, p) dbel = 10 - int(lev) lab = "%ddB" % (dbel, ) plt.plot(x, data, linefmt, label=lab) plt.legend() plt.savefig("plot-%s-perfp.png" % noise)
def calc_f(data): prf = stats.prf(data) return (("f measure", ), (prf["f"], ), (None, ))
def calc_pr(data): prf = stats.prf(data) return (("Precision", "Recall"), (prf["precision"] * 100, prf["recall"] * 100), ("%%", "%%"))
def calc_f(data): prf = stats.prf(data) return (("f measure", ), (prf["f"],), (None, ))
def calc_pr(data): prf = stats.prf(data) return (("Precision", "Recall"), (prf["precision"]*100, prf["recall"]*100), ("%%", "%%"))