Last answered:

21 Oct 2020

Posted on:

19 Aug 2020


Prediction using the LSTM model for long-term has problems with the final step which is the generating of future predicted values

Hi, I'm working on research for temperature prediction using the LSTM model for long-term prediction but I faced some problems with the final step which is the generating of future predicted values. My historical temperature data range from (0.41°C to 40°C)  while the generated of future predicted values varying between (20°C to 30°C) which are not normal ( please see the attached image). I think there is a problem in my code (my code which covers the future predicted part is below).Please I need some help to solve this issue.   from sklearn.preprocessing import MinMaxScaler
#from sklearn.preprocessing import StandardScaler
scaler = MinMaxScaler()
train = scaler.transform(train)
test = scaler.transform(test)
#train = scaler.transform(train)
#test = scaler.transform(test)
train = scaler.transform(train)   time_steps = 450
n_features = 1   history =
X_train, y_train,
)   pred_list = [ ] batch = train[-time_steps:].reshape((1, time_steps, n_features)) for i in range(time_steps):
batch = np.append(batch[:,1:,:],[[pred_list[i]]],axis=1)   from pandas.tseries.offsets import DateOffset
add_dates = [df.index[-1] + DateOffset(days=x) for x in range(0,452) ]
future_dates = pd.DataFrame(index=add_dates[1:],columns=df.columns)   df_predict = pd.DataFrame(scaler.inverse_transform(pred_list),
index=future_dates[-time_steps:].index, columns=['Prediction']) df_proj = pd.concat([df,df_predict], axis=1)   plt.figure(figsize=(20, 5))
plt.plot(df_proj.index, df_proj['Air temperature | (\'C)'])
plt.plot(df_proj.index, df_proj['Prediction'], color='r')
plt.legend(loc='best', fontsize='xx-large')
plt.ylabel('Temperature °C')
plt.xlabel('Time Step')
plt.legend()     Thank you and sorry for any inconvenience. 1- historical data and future predicted values
1 answers ( 0 marked as helpful)
Posted on:

21 Oct 2020

Hi Fahad,  could you indicate as to which course and which lecture this is related to? Thanks in advance.    Best,  The 365 Team

Submit an answer