LSTM Predict number from sequence of numbers

Viewed 100

I am trying to train an LSTM to predict some numbers from a sequence of number. My X dataset has 33 features and my Y dataset has 4 variables that I have to predict for each X sample. For example:

Xdf:

enter image description here

Ydf:

enter image description here

After I turn X, y to numpy arrays and reshape the data I build the below model:

enter image description here

I get the following results with huge loss and distinct overfitting. Any ideas what I am doing wrong and I am getting these results? Thanks.

enter image description here

Xdf: https://drive.google.com/file/d/1wH56E0M3ok1MGWzU6FGKgDJF7EZfL_7f/view?usp=sharing

ydf: https://drive.google.com/file/d/1RkjWl1FIiQDyjkRvl7ZQKTOXIE8FtBXA/view?usp=sharing

UPDATE

I edited my code the following way and it seems to bee working a tiny bit better. Still huge loss and overfitting but after some epochs it seemed it worked fine for a while. Any suggestions on how to reduce loss and overfitting would be appreciated.

X = X.reshape((X.shape[0], 33, 1)) # (5850, 33, 1)
model = tf.keras.Sequential()
model.add(layers.LSTM(50, activation='relu', input_shape=(33, 1)))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
model.add(layers.Dense(4))
early_stopping = EarlyStopping(monitor='val_loss', patience=42)  
model.compile(optimizer=tf.keras.optimizers.Adam(0.01), loss=tf.keras.losses.MeanSquaredError(), metrics=['accuracy'])
model.fit(X, y, epochs=200, verbose=1, validation_split = 0.2)
0 Answers
Related