LSTM model has poor prediction results

Viewed 213

#Forecast future runoff based on meteorological data and historical runoff

Streamflow=pd.read_csv('###.csv', delimiter=',')
x = Streamflow.drop('Q',axis=1)   
Y = Streamflow['Q']               
X = np.array(x)                   
y = np.array(Y)
            
test_size = int(len(X) * 0.15)
valid_size = int(len(X) * 0.15)
train_size= len(X) - (valid_size+test_size)
y_train, y_valid, y_test = y[0:train_size], y[train_size:train_size+valid_size], y[-test_size:]
X_train, X_valid, X_test = X[0:train_size], X[train_size:train_size+valid_size], X[train_size+valid_size:]

X_train = np.reshape(X_train, (X_train.shape[0], 1, X_train.shape[1]))  
X_valid = np.reshape(X_valid, (X_valid.shape[0], 1, X_valid.shape[1]))
X_test = np.reshape(X_test, (X_test.shape[0], 1, X_test.shape[1]))
input=X_train[1:]
input_shape=X_train.shape[1:]
print (y_train.shape, y_valid.shape, y_test.shape)

model = Sequential()
model.add(LSTM(150, input_shape=X_train.shape[1:], activation='relu',return_sequences=True))
model.add(Dropout(0.3))
model.add(LSTM(300, activation='relu'))
model.add(Dropout(0.3))
model.add(Dense(200, activation='relu'))
model.add(Dropout(0.6))
model.add(Dense(1, activation='relu'))                                     

optimizer = tf.keras.optimizers.SGD(learning_rate=e_LR) 
model.compile(optimizer=optimizer,loss='MeanAbsoluteError')  
history = model.fit(X_train, y_train, epochs=e_epoch, batch_size=e_batch_size, verbose=0, validation_data=(X_valid, y_valid), shuffle=True)

enter image description here This is model loss and the result. The results of the training period and the verification period are acceptable, but the results of the testing period are too poor. How should I modify the model? (The data is not normalized because the normalized prediction is a straight line. )

1 Answers

Sorry, my reputation is not enough for me to comment directly. You can try the following three solutions: 1. Reduce the learning rate as much as possible 2. Reduce the model complexity, such as reducing the hidden size of LSTM. 3. Increase the number of training rounds.

Related