# Store "window" points as a sequence xin = [] next_X1 = [] for i in range(window,len(Xtest)): xin.append(Xtest[i-window:i]) next_X1.append(Xtest[i]) # Reshape data to format for LSTM xin, next_X1 = np.array(xin), np.array(next_X1) xin = xin.reshape((xin.shape[0], xin.shape[1], 1)) # Predict the next value (1 step ahead) X_pred = m.predict(xin) # Plot prediction vs actual for test data plt.figure() plt.plot(X_pred,':',label='LSTM') plt.plot(next_X1,'--',label='Actual') plt.legend()