Hello, I have the problem, that my LSTM Model does noth predict the correct output.

It does not predict the correct training output, although it was trained with this output…nor does it predict the correct test data output.

Can anyone help?

You can find the data here:

https://www.dropbox.com/s/72vxi82s5f7idan/datas.csv?dl=0

And here is my code (but don’t know if that helps, since something seems to be really wrong ?!):

import pandas as pd

import tensorflow as tf

import pandas as pd

from tensorflow.keras import layers

from keras.models import Sequential

import numpy as np

from keras.layers import LSTM

from keras.layers import Dense

df_svt = pd.read_csv(“D:/datas.csv”, sep=“;”)

df_svt = df_svt.iloc[6980:]

df_svt = df_svt.iloc[:8158]

df_y = pd.DataFrame(df_svt.y)

df_y_train = df_y.iloc[:6501]

df_y_test = df_y.iloc[6501:8158]

y_train = df_y_train.to_numpy()

y_test = df_y_test.to_numpy()

df_svt = df_svt.drop(columns=[“y”])

df_x_train = df_svt.iloc[:6501]

df_x_test = df_svt.iloc[6501:8158]

x_train = df_x_train.to_numpy()

x_test = df_x_test.to_numpy()

train_X = x_train.reshape(6501,1,7)

test_X = x_test.reshape(1657,1,7)

train_Y = y_train.reshape(6501,1)

test_Y = y_test.reshape(1657,1)

model = tf.keras.Sequential()

model.add(LSTM(units=70,recurrent_activation=“sigmoid”, return_sequences=True , input_shape=(train_X.shape[1],train_X.shape[2]) ))

model.add(LSTM(units=70, recurrent_activation=“sigmoid”,return_sequences=True))

model.add(LSTM(units=30, recurrent_activation=“sigmoid”, return_sequences=False,activation=“softmax” ))

model.add(Dense(units=1))

model.compile(optimizer=“adam”,loss=“mean_squared_error”, metrics=“accuracy”)

model.fit(train_X, train_Y, epochs=200, verbose=1)

model.summary()

train = model.predict(train_X)

predict = model.predict(test_X)

print(train)

print(predict)