I have built a set of python scripts. The scripts perform the following tasks-
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.
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.
My question is - How do I minimize the variation in the predicted values?
Thanks in advance, Sanjay S
Here's a sample code I am using.
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')
If the variation in the values predicted by your model is high, then it suggests that your model isn't trained well enough. Please train your model further by increasing the number of epochs and add a couple of more layers to your model.
Also I would suggest you to add appropriate activation functions to the layers of your model.