预测代码里只计算了测试集的rmse,得出额外预测值后,想要和刚刚从台站获取的真实值做对比,计算一下误差,又不愿意在预测程序里添加代码,但Excel的计算确实不是很懂,只能新开一个py单独计算:
import math
import xlrd
from sklearn.metrics import mean_squared_error # 用于评估模型
workbook = xlrd.open_workbook('D:\python\PyCharm\Rainfall_LSTM\D7.xlsx', 'r')
sheet1 = workbook.sheet_by_index(0)
predictnew = sheet1.col_values(0)[1:] # 第一列为最新的预测值
predictold = sheet1.col_values(1)[1:] # 第二列为之前的预测值
true = sheet1.col_values(2)[1:] # 第三列为真实值
newScore = math.sqrt(mean_squared_error(predictnew, true))
oldScore = math.sqrt(mean_squared_error(predictold, true))
print u'The new rmse is', newScore
print u'The old rmse is', oldScore
import math
import xlrd
from sklearn.metrics import mean_squared_error # 用于评估模型
workbook = xlrd.open_workbook('D:\python\PyCharm\Rainfall_LSTM\D7.xlsx', 'r')
sheet1 = workbook.sheet_by_index(0)
predictnew = sheet1.col_values(0)[1:] # 第一列为最新的预测值
predictold = sheet1.col_values(1)[1:] # 第二列为之前的预测值
true = sheet1.col_values(2)[1:] # 第三列为真实值
newScore = math.sqrt(mean_squared_error(predictnew, true))
oldScore = math.sqrt(mean_squared_error(predictold, true))
print u'The new rmse is', newScore
print u'The old rmse is', oldScore
不过输出结果却让我很尴尬,新的预测不如老的预测???还被同事质问了。。。事实证明,修改网络的超参数要谨慎!