是否有使用Python中的NARX模型训练和预测/推断数据的端到端示例?
有图书馆PyNeurgen NARX PyNeurgen library
但是PyNeurgen的文档不是很完整。
该OP似乎已经编写了Keras实现,但是代码缺少用于推理/预测的实现。 NARX implementation using keras
python参考方案
我认为您正在寻找model.fit()和model.predict()的等效项,它们是pyneurgen中的net.learn()和net.test()。基于此tutorial和example,我编写了此演示(在python 2.7中),以使您了解如何完成此演示。希望对您有所帮助。
import math
import numpy as np
import matplotlib.pylab as plt
from pyneurgen.neuralnet import NeuralNet
from pyneurgen.recurrent import NARXRecurrent
def plot_results(x, y, y_true):
plt.subplot(3, 1, 1)
plt.plot([i[1] for i in population])
plt.title("Population")
plt.grid(True)
plt.subplot(3, 1, 2)
plt.plot(x, y, 'bo', label='targets')
plt.plot(x, y_true, 'ro', label='actuals')
plt.grid(True)