title: Keras NN model unable to predict future values
body: <p>I'm attempting to predict future prices for a stock (lol practicing for gamestop), but I end up predicting values that I already have in my data. (Model is unable to predict values in the future). I have tried creating a future column that is the price but shifted back by the amount of days I want to predict - Looking to predict a month into the future (days_ahead= 31). Some dependencies may be missing.</p>
  <pre><code>import numpy as np
  from numpy import loadtxt
  import matplotlib.pyplot as plt
  from sklearn.preprocessing import scale
  #from TFANN import ANNR
  #import pandas as pd
  from google.colab import files
  import tensorflow as tf
  
  import random
  #import yahoo_fin
  
  
  df2 = web.DataReader('KO', data_source = 'yahoo', start = '1/27/2020', end = '1/29/2021')
  
  days_ahead = 31
  
  df2['Future'] = df2['Close'].shift(-days_ahead)
  
  
  
  # get them before droping NaNs
  last_sequence = np.array(df2['Future'].tail(days_ahead))
  # drop NaNs
  df2.dropna(inplace=True)
  
  
  
  
  
  train_data = scaled_data[0:training_data_len , :]
  
  #Split the data into x_train and y_train data sets
  step = 100
  
  
  x_train = []
  y_train = []
  
  for i in range(step, len(train_data)):
    x_train.append(train_data[i- step: i, 0])
    y_train.append(train_data[i, 0])
  
  
  print(x_train)
  print(y_train)
  
  
  from tensorflow import keras
  from keras.models import Sequential
  from keras.layers import Dense
  
      # np.random.seed(314)
      # tf.random.set_seed(314)
  
  model = Sequential()
  model.add(LSTM(100, return_sequences=True, input_shape= (x_train.shape[1], 1), ))
  model.add(LSTM(100, return_sequences=False))
  model.add(Dropout(0.2))
  model.add(Dense(25))
  model.add(Dropout(0.2))
  model.add(Dense(1, kernel_initializer='normal'))
  
  model.compile(optimizer='adam', loss='mean_squared_error')
  
  model.fit(x_train, y_train, batch_size=32, epochs=10)
  
  
  Epoch 1/10
  3/3 [==============================] - 0s 120ms/step - loss: 0.0198
  Epoch 2/10
  3/3 [==============================] - 0s 126ms/step - loss: 0.0164
  Epoch 3/10
  3/3 [==============================] - 0s 124ms/step - loss: 0.0280
  Epoch 4/10
  3/3 [==============================] - 0s 121ms/step - loss: 0.0181
  Epoch 5/10
  3/3 [==============================] - 0s 121ms/step - loss: 0.0217
  Epoch 6/10
  3/3 [==============================] - 0s 123ms/step - loss: 0.0212
  Epoch 7/10
  3/3 [==============================] - 0s 119ms/step - loss: 0.0240
  Epoch 8/10
  3/3 [==============================] - 0s 130ms/step - loss: 0.0232
  Epoch 9/10
  3/3 [==============================] - 0s 124ms/step - loss: 0.0202
  Epoch 10/10
  3/3 [==============================] - 0s 121ms/step - loss: 0.0136
  &lt;tensorflow.python.keras.callbacks.History at 0x7fc4c15d07f0&gt;
  
  
  # make testing data set
  # make new array with scaled values 
  test_data = scaled_data[training_data_len - step: , :]
  #Create  x_test and y_test
  x_test = []
  y_test = stock_data[training_data_len:, :]
  for i in range(step, len(test_data)):
    x_test.append(test_data[i-step:i, 0])
  
  x_test = np.array(x_test)
  x_test = np.reshape(x_test, (x_test.shape[0], x_test.shape[1], 1 ))
  
  pricePredict = model.predict(x_test)
  pricePredict = scaler.inverse_transform(pricePredict)
  
  sum_square_error = 0.0
  for i in range(len(pricePredict)):
      sum_square_error += (pricePredict[i] - y_test[i])**2.0
  mean_square_error = 1.0 / len(pricePredict) * sum_square_error
  print(mean_square_error)
  
  train = data[:training_data_len]
  valid = data[training_data_len:]
  valid['Prediction'] = pricePredict
  
  plt.figure(figsize =(16,8))
  plt.title('Stock Price History vs Model Prediction')
  plt.plot(train['Future'])
  plt.plot(valid[['Future', 'Prediction']])
  
  plt.plot()
  plt.xlabel('Date', fontsize=16)
  plt.ylabel('Close Price USD ($)', fontsize=16)
  plt.legend()
  plt.show()
  
  </code></pre>
  <p>If you look at the plot, you can see that the prediction line doesn't go past the actual price, meaning
  no new values are being predicted. Is there a possible fix for this? Sorry if the answers really obvious I'm a beginner to ml.</p>