Commits

Matteo Bertini  committed 07191e0

Add sh/plot-lcurve.py

  • Participants
  • Parent commits 7380878

Comments (0)

Files changed (1)

File seasonal/sh/plot-lcurve.py

+#!/usr/bin/env python
+
+import glob
+
+from pylab import *
+
+def load(f):
+    return [float(x) for x in open(f) if x.strip()]
+
+def n(f):
+    return f.split("/")[1].split(".")[0]
+
+def o(f):
+    if 'sarima' in f:
+        return 'x-'
+    elif 'rbf-s' in f or 'lin' in f:
+        return 'o-'
+    elif 'rbf' in f or 'nn' in f:
+        return '*-'
+    else:
+        return '.-'
+
+print "all"
+fig = figure(figsize=(6,8))
+plt = fig.add_subplot(111)
+plt.set_title("Learning curve")
+for f in glob.glob("results/*.lcurve"):
+    y = load(f)
+    x = [i+1 for i in range(len(y))]
+    label = n(f) if n(f) in ('arima_kal', 'rw', 'smean') else None
+    plt.plot(x, y, o(f), label=label)
+plt.legend(loc='best')
+plt.grid()
+savefig("results/lcurve-all.pdf")
+
+print "top"
+fig = figure(figsize=(6,8))
+plt = fig.add_subplot(111)
+plt.set_title("Learning curve (detail)")
+for f in [f for f in glob.glob("results/*.lcurve") if n(f) not in ('arima_kal', 'rw', 'smean')]:
+    y = load(f)
+    x = [i+1 for i in range(len(y))]
+    plt.plot(x, y, o(f), label=n(f))
+plt.legend()
+plt.grid()
+savefig("results/lcurve-top.pdf")
+