Python “我该怎么做?”;量度;Keras中时间序列预测代码的性能?

Python “我该怎么做?”;量度;Keras中时间序列预测代码的性能?,python,deep-learning,time-series,keras,forecasting,Python,Deep Learning,Time Series,Keras,Forecasting,我对在Keras中进行时间序列预测非常陌生。对于我正在研究的问题,我想知道我的模型的性能如何。我想知道一些完成这项任务的最佳实践。请提前提出建议,并表示感谢。我假设您希望查看您的型号的准确性和损耗: model.compile(...) model.fit(...) eval_loss, eval_accuracy = model.evaluate(test_set, test_set, batch_size=b

我对在Keras中进行时间序列预测非常陌生。对于我正在研究的问题,我想知道我的模型的性能如何。我想知道一些完成这项任务的最佳实践。请提前提出建议,并表示感谢。

我假设您希望查看您的型号的
准确性
损耗

model.compile(...)
model.fit(...)
eval_loss, eval_accuracy = model.evaluate(test_set, test_set,
                                          batch_size=batch_size, verbose=1)
print("Accuracy: {:.2f}%".format(eval_accuracy * 100))
print("Loss: {}".format(eval_loss))
您甚至可以绘制一张图表来查看培训过程中的损失和准确性:

import matplotlib.pyplot as plt
history = model.fit(...)        

summarize history for accuracy 
plt.figure(1)
plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()

# summarize history for loss
plt.figure(1)
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
编辑

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame(columns=['Series', 'Scale Signal'])

history = model.fit(...)
predicted = model.predict(test_input)

df_val_loss = pd.DataFrame(history.history['val_loss'])
df_val_loss.plot()

df_predicted = pd.DataFrame(predicted).T
df_predicted.columns = ['Predicted']

df_result = pd.concat([df, df_predicted], ignore_index=True)
df_result.plot()

plt.show()
上面的脚本获取并绘制预测数据和验证损失。我不太经常使用时间序列,因此根据我的经验,我不能给你任何建议,但这里有一些好的链接,我希望可以帮助你:


    • 我在这里找到了答案。对于我正在研究的一个回归问题,布朗利博士解释了三种方法:绝对平均误差、均方误差和R^2:这正是我想要的。感谢所有人的帮助和缺点

      这个问题太宽泛了,你必须问一个具体的问题。这假设分类,可能不是这样。嗨,Huy,我的问题不是分类问题。我正在处理一个时间序列预测问题。我想知道是否有良好的实践,我应该遵循,以检查模型是否正常工作。谢谢你的回答。