【发布时间】:2018-06-11 02:17:38
【问题描述】:
我对在 Keras 中进行时间序列预测非常陌生。对于我正在处理的问题,我想知道我的模型的性能如何。我想知道完成这项任务的一些最佳实践。请告知,并提前致谢。
【问题讨论】:
-
这个问题太笼统了,你得问一个具体的问题。
标签: python deep-learning time-series keras forecasting
我对在 Keras 中进行时间序列预测非常陌生。对于我正在处理的问题,我想知道我的模型的性能如何。我想知道完成这项任务的一些最佳实践。请告知,并提前致谢。
【问题讨论】:
标签: python deep-learning time-series keras forecasting
我假设您要查找模型的 accuracy 和 loss:
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()
上述脚本获取并绘制预测数据和验证损失。我不经常使用时间序列,所以我无法根据我的经验给你任何建议,但这里有一些很好的链接,希望可以帮助你:
【讨论】:
我实际上在这里找到了答案。对于我正在研究的回归问题,Brownlee 博士解释了三种方法:平均绝对误差、均方误差和 R^2:LINK 这正是我所寻找的。感谢大家的帮助和负面意见!
【讨论】: