def PlotLearn(R, A, Y):
intA = [BinVecToInt(j) for j in A]
intY = [BinVecToInt(j) for j in Y]
fig, ax = mpl.subplots(figsize=(20, 10))
ax.plot(intA, intY, label ='Orig')
l, = ax.plot(intA, intY, label ='Pred')
ax.legend(loc = 'upper left')
#Updates the plot in ax as model learns data
def UpdateF(i):
R.fit(A, Y)
YH = R.predict(A)
S = MSE(Y, YH)
intYH = [BinVecToInt(j) for j in YH]
l.set_ydata(intYH)
ax.set_title('Iteration: ' + str(i * 64) + ' - MSE: ' + str(S))
return l,
ani = mpla.FuncAnimation(fig, UpdateF, frames = 2000, interval = 128, repeat = False)
#ani.save('foo.gif')
mpl.show()
return ani
评论列表
文章目录