为什么我的预测不正确,准​​确度 = 00,我该如何训练我的数据并解决我的问题

why my predictions is not correct , and accuracy = 00 , how can i train my data and fixe my problem

df_btc1=df_btc.sort_index(ascending=True,axis=0)
new_dataset=pd.DataFrame(index=range(0,len(df_btc)),columns=['Date','Close'])
L=len(df_btc)

for i in range(0,len(df_btc1)):
    new_dataset["Date"][i]=df_btc1['Date'][i]
    new_dataset["Close"][i]=df_btc1["Close"][i]

#Normalize the Dataset
scaler=MinMaxScaler(feature_range=(0,1))
new_dataset.index=new_dataset.Date
new_dataset.drop("Date",axis=1,inplace=True)
final_dataset=new_dataset.values

train_data=final_dataset[0:L-300,:]
valid_data=final_dataset[L-300:,:]
scaled_data=scaler.fit_transform(final_dataset)

x_train_data,y_train_data=[],[]

for i in range(300,len(train_data)):
    x_train_data.append(scaled_data[i-300:i,0])
    y_train_data.append(scaled_data[i,0])
x_train_data,y_train_data=np.array(x_train_data),np.array(y_train_data)
x_train_data=np.reshape(x_train_data,(x_train_data.shape[0],x_train_data.shape[1],1))

#Build and train the LSTM model
lstm_model=Sequential()
lstm_model.add(LSTM(units=50,return_sequences=True,input_shape=(x_train_data.shape[1],1)))
lstm_model.add(Dropout(0.2))
lstm_model.add(LSTM(units=50, return_sequences=True))
lstm_model.add(Dropout(0.2))

lstm_model.add(LSTM(units=50, return_sequences=True))
lstm_model.add(Dropout(0.2))

lstm_model.add(LSTM(units=50))
lstm_model.add(Dropout(0.2))
lstm_model.add(Dense(1))

inputs_data=new_dataset[len(new_dataset)-len(valid_data)-300:].values
inputs_data=inputs_data.reshape(-1,1)
inputs_data=scaler.transform(inputs_data)

lstm_model.compile(loss='binary_crossentropy', metrics=['accuracy'],optimizer='adam')
lstm_model.fit(x_train_data,y_train_data,epochs=5,batch_size=5,verbose=2)

纪元 1/5 280/280 - 91s - 损失:0.3312 - 精度:0.0000e+00 - 91s/epoch - 324ms/step 纪元 2/5 280/280 - 85s - 损失:0.3344 - 精度:0.0000e+00 - 85s/epoch - 305ms/step 时代 3/5 280/280 - 83s - 损失:0.3286 - 精度:0.0000e+00 - 83s/epoch - 298ms/step 时代 4/5 280/280 - 84s - 损失:0.3267 - 精度:0.0000e+00 - 84s/epoch - 299ms/step 纪元 5/5 280/280 - 83s - 损失:0.3297 - 精度:0.0000e+00 - 83s/epoch - 297ms/步

enter image description here

损失 loss='binary_crossentropy' 适用于二元分类问题,但不适用于时间序列预测问题。 对于时间序列预测,您应该使用均方误差。 此外,您不能将 accuracy 用于非分类问题,因此只需从代码中删除 metrics,给出:

lstm_model.compile(loss=tf.keras.losses.MeanSquaredError(), optimizer='adam')