我是Python的新手。我正在关注此代码示例,我喜欢提取未来的五个周期值(作为预测)。有人可以帮我吗?
完整代码链接如下: https://github.com/sagarmk/Forecasting-on-Air-pollution-with-RNN-LSTM/blob/master/forecasting.py
我正在尝试从代码末尾提取未来的五个周期预测:
# evaluating model
# make a prediction
from math import sqrt
from numpy import concatenate
yhat = model.predict(test_X)
test_X = test_X.reshape((test_X.shape[0], test_X.shape[2]))
inv_yhat = concatenate((yhat, test_X[:, 1:]), axis=1)
inv_yhat = scaler.inverse_transform(inv_yhat)
inv_yhat = inv_yhat[:,0]
inv_y = scaler.inverse_transform(test_X)
inv_y = inv_y[:,0]
# calculate RMSE
rmse = sqrt(mean_squared_error(inv_y, inv_yhat))
print('Test RMSE: %.3f' % rmse)
非常感谢您的所有帮助。