Go to the documentation of this file.00001 import numpy as np
00002 import matplotlib.pylab as plt
00003
00004 import sys
00005 import os
00006 import os.path
00007
00008
00009 def plot_statistics(folder):
00010 for f in os.listdir(folder):
00011 if f[-3:] != "txt":
00012 continue
00013 filename = os.path.join(folder, f)
00014
00015 data = np.genfromtxt(filename, dtype=float, delimiter=' ', names=True)
00016
00017 precision = data['tp'] / (data['tp']+data['fp'])
00018 recall = data['tp'] / (data['tp']+data['fn'])
00019 seg_acc = data['tp'] / (data['tp']+data['fp']+data['fn'])
00020
00021 time = data['time'] - data['time'][0]
00022
00023
00024 precision[np.where(np.isnan(precision))] = 0.
00025 recall[np.where(np.isnan(recall))] = 0.
00026 seg_acc[np.where(np.isnan(seg_acc))] = 0.
00027
00028 plt.figure(figsize=(7.5,5))
00029 plt.plot(time, seg_acc, "k", label="seg_acc", lw=3.0)
00030 plt.plot(time, precision, "b", label="precision", lw=2.0, ls="--")
00031 plt.plot(time, recall, "r", label="recall", lw=2.0, ls="--")
00032
00033 plt.xlim(0, data['time'][-1] - data['time'][0])
00034 plt.ylim(-0.1, 1.1)
00035 plt.xlabel("time")
00036
00037 plt.title(os.path.basename(filename[:-3]))
00038 plt.legend(loc=4)
00039
00040
00041 if __name__ == "__main__":
00042 if len(sys.argv) != 2:
00043 print "Usage: plot_statistics.py <experiment folder>"
00044 sys.exit()
00045
00046 plot_statistics(sys.argv[1])
00047
00048 plt.show()
00049