我目前正在尝试通过使用多元输入来构建 LSTM 模型,但我不明白我预测的确切输出是什么。
我目前正在使用数据中的 5 个特征作为输入数据:
X_data = data[['Time', 'Avg CPU Load', 'F1', 'F2', 'F3']]
我的主要目标是通过使用其他功能作为输入数据来预测“平均 CPU 负载”,但我不确定我是否这样做。
在这些功能中,我将“时间”作为数据框中的索引。然后我在下面的代码中使用了 60 个时间步。
new_X_train=[]
new_Y_train=[]
for i in range(len(X_data)-timesteps-1):
t=[]
for j in range(0,timesteps):
t.append(X_data[[(i+j)], :])
new_X_train.append(t)
new_Y_train.append(X_data[i+ timesteps,1])
变量“new_X_train”和“new_Y_train”具有必须插入模型的输入数据。然后我定义我的模型。
sq = Sequential()
sq.add(LSTM(units = 100, return_sequences = True,
input_shape = (None, 4)))
sq.add(Dropout(0.2))
sq.add(LSTM(units = 100,return_sequences = True))
sq.add(Dropout(0.2))
sq.add(LSTM(units = 100,return_sequences = True))
sq.add(Dropout(0.2))
sq.add(LSTM(units = 100))
sq.add(Dropout(0.2))
sq.add(Dense(units=1)) # only one output
sq.compile(optimizer = 'adam', loss = 'mean_squared_error')
sq.fit(new_X_train, new_Y_train, epochs = 5, batch_size = 20)
训练模型后,我加载测试数据并实施 60 个时间步长。IE:我对训练数据做同样的事情,然后我使用X_test
数据来预测值。
predicted = sq.predict(X_test)
现在我不确定上面的代码预测的是什么输出,比如它试图预测什么特征?
以及如何让我的模型预测“平均 CPU 负载”功能?