__author__ = 'martslaaf' import numpy as np from matplotlib.pyplot import plot, show from wavenet import wavelon_class_constructor, trainer coun = 3000 inp_s = map(lambda x: float(x.split(',')[0]), open('/home/martslaaf/Learn_Coding/pybrain/sig.csv').readlines()) outp_s = map(lambda x: float(x.split(',')[1]), open('/home/martslaaf/Learn_Coding/pybrain/sig.csv').readlines()) inp_o = map(lambda x: float(x.split(',')[0])-150, open('/home/martslaaf/Learn_Coding/pybrain/orig.csv').readlines()) outp_o = map(lambda x: float(x.split(',')[1]), open('/home/martslaaf/Learn_Coding/pybrain/orig.csv').readlines()) ds = [] for i in xrange(coun): ds.append((np.array([inp_s[i]]), np.array([outp_s[i]]))) vs = [] for i in xrange(301): vs.append((np.array([inp_o[i]]), np.array([outp_o[i]]))) n = wavelon_class_constructor() n = n(1, 1, 19) k = 0 track = trainer(300, ds, vs, n) outew = [] print track for j in vs: outew.append(n.forward(j[0])[0][0]) plot(outp_o, 'g') plot(outew, 'r') show()
def main_async_method(queue, n): track = trainer(50, ds, vs, n) queue.put({'mse': track[-1]})
coun = 3800 FB = map(lambda x: float(x.split(';')[7]), open('/home/martslaaf/Pictures/Finance/GOOG.csv').readlines()[:3880]) shift_1 = FB[4:coun + 4] shift_2 = FB[3:coun + 3] shift_3 = FB[2:coun + 2] shift_4 = FB[1:coun + 1] shift_5 = FB[:coun] no_shift = FB[5:coun + 5] tr = [] va = [] for i in xrange(coun - 1000): tr.append( (np.array([shift_1[i], shift_2[i], shift_3[i], shift_4[i], shift_5[i]]), np.array([no_shift[i]]))) for i in xrange(coun - 1000, coun): va.append( (np.array([shift_1[i], shift_2[i], shift_3[i], shift_4[i], shift_5[i]]), np.array([no_shift[i]]))) n = wavelon_class_constructor(frame=(-200, 200), period=100) n = n(5, 1, 19) k = 0 track = trainer(100, tr, va, n) outew = [] print track for j in va: outew.append(n.forward(j[0])[0][0]) plot(no_shift[coun - 1000:coun], 'g') plot(outew, 'r') show()
def main_async_method(queue, n): track = trainer(50, ds, vs, n) queue.put({"mse": track[-1]})
__author__ = "martslaaf" import numpy as np from matplotlib.pyplot import plot, show from wavenet import wavelon_class_constructor, trainer inp_1 = map(lambda x: float(x), open("/home/martslaaf/Pictures/old_data/nonlinear_xor_1.csv").readlines()) inp_2 = map(lambda x: float(x), open("/home/martslaaf/Pictures/old_data/nonlinear_xor_2.csv").readlines()) inp_3 = map(lambda x: float(x), open("/home/martslaaf/Pictures/old_data/nonlinear_sum.csv").readlines()) outp = map(lambda x: float(x), open("/home/martslaaf/Pictures/old_data/nonlinear_target.csv").readlines()) coun = 1000 tr = [] va = [] for i in xrange(coun - 250): tr.append((np.array([inp_1[i], inp_2[i], inp_3[i]]), np.array([outp[i]]))) for i in xrange(coun - 250, coun): va.append((np.array([inp_1[i], inp_2[i], inp_3[i]]), np.array([outp[i]]))) n = wavelon_class_constructor(frame=(-200, 200), period=100) n = n(3, 1, 19) k = 0 track = trainer(10000, tr, va, n) outew = [] print track for j in va: outew.append(n.forward(j[0])[0][0]) plot(outp[coun - 250 : coun], "g") plot(outew, "r") show()
from matplotlib.pyplot import plot, show from wavenet import wavelon_class_constructor, trainer coun = 3000 inp_s = map(lambda x: float(x.split(',')[0]), open('/home/martslaaf/Learn_Coding/pybrain/sig.csv').readlines()) outp_s = map(lambda x: float(x.split(',')[1]), open('/home/martslaaf/Learn_Coding/pybrain/sig.csv').readlines()) inp_o = map(lambda x: float(x.split(',')[0]) - 150, open('/home/martslaaf/Learn_Coding/pybrain/orig.csv').readlines()) outp_o = map(lambda x: float(x.split(',')[1]), open('/home/martslaaf/Learn_Coding/pybrain/orig.csv').readlines()) ds = [] for i in xrange(coun): ds.append((np.array([inp_s[i]]), np.array([outp_s[i]]))) vs = [] for i in xrange(301): vs.append((np.array([inp_o[i]]), np.array([outp_o[i]]))) n = wavelon_class_constructor() n = n(1, 1, 19) k = 0 track = trainer(300, ds, vs, n) outew = [] print track for j in vs: outew.append(n.forward(j[0])[0][0]) plot(outp_o, 'g') plot(outew, 'r') show()