title: How do we make the predictions using RNN - LSTM using python more consistent?
body: <p>I have built a set of python scripts. The scripts perform the following tasks- </p>
  
  <ol>
  <li>fetch stock prices information based on user inputs (Stock symbol, start date, end date etc.)</li>
  <li>build and train a model on the stock price information</li>
  <li>predict the next predicted price and the associated RMSE (Root Mean Square Error)</li>
  <li>write the output along with user inputs into an xlsx file</li>
  </ol>
  
  <p>So far so good, it does all of the above in a decent manner. However, every time I execute the scripts (2) and (3) with identical data and user inputs, I get different predicted values. I do understand that these are predictions and that the predicted values would vary even though all factors remain identical.</p>
  
  <p>Say for example, if the pred value of trial#1 is 100, then the pred value of trial#2 could be 105, and the pred value of trial#3 is 95, and so on. This variation of (plus/minus) 5 is acceptable. But the pred values cannot be in the range of 80 to 120.</p>
  
  <p>My question is - <strong>How do I minimize the variation in the predicted values?</strong></p>
  
  <p>Thanks in advance,
  Sanjay S</p>
  
  <p>Here's a sample code I am using.</p>
  
  <pre><code>from sklearn.preprocessing import MinMaxScaler
  from keras.models import Sequential
  from keras.layers import Dense, LSTM, Dropout
  from tensorflow.python.util import deprecation
  
  model = Sequential()
  lstm1 = LSTM(units=60, return_sequences=True, input_shape = (x_train.shape[1],1))
  lstm2 = LSTM(units=60, return_sequences=True)
  lstm3 = LSTM(units=60)
  dropOut = Dropout(0.2)
  dense = Dense(units=1)
  
  model.add(lstm1)
  model.add(dropOut)
  
  model.add(lstm2)
  model.add(dropOut)
  
  model.add(lstm2)
  model.add(dropOut)
  
  model.add(lstm3)
  model.add(dropOut)
  
  model.add(dense)
  model.compile(optimizer='adam', loss='mean_squared_error')
  </code></pre>