我有65个样本的数据。例如:2697,2825,2136,2824,3473,2513,2538,3051,2737.9805,3133.849,2350.8695,6000,3121.225
我在训练和测试(训练和测试)中划分了数据,对其进行了缩放并对其进行了监督。我必须预测第66个样本值是什么。
2697,2825,2136,2824,3473,2513,2538,3051,2737.9805,3133.849,2350.8695,6000,3121.225,?,?,?
我尝试了各种方法。其中之一是:
enter code here
lstm_model = fit_lstm(train_scaled, 1, 100, 4)
train_reshaped = train_scaled[:, 0].reshape(len(train_scaled), 1, 1)
lstm_model.predict(train_reshaped, batch_size=1)
predictions = list()
expected = list()
for i in range(len(test_scaled)):
X, y = test_scaled[i, 0:-1], test_scaled[i, -1]
yhat = forecast_lstm(lstm_model, 1, X)
# invert scaling
yhat = invert_scale(scaler, X, yhat)
yhat = pred(raw_values, yhat, len(test_scaled)-i+1)
# store forecast
predictions.append(yhat)
expected_1 = raw_values[len(train) + i]
expected.append(expected_1)
print('Predicted=%f, Expected=%f' % (yhat, expected_1))
任何领导都会有所帮助。
先谢谢。