簡體   English   中英

使用 LSTM python 預測新值

[英]Forecasting new value using LSTM python

我已經建立了一個可以預測未來價格的 LSTM 模型。 我已經用已經存在的地面真值進行了測試,以了解模型的准確性。 現在我想使用相同的模型來預測我們不知道基本事實的值。我做了下面的代碼來對 449 條新記錄進行預測。

Test = Stock_AREIT[len(Stock_AREIT)-60:]
Test=Test['1. open']
inputs=Test.values
inputs = inputs.reshape(-1,1)

# Scale inputs but not actual test values
inputs = sc.transform(inputs)
for test in range(0,449):
inputs=np.append(inputs,predicted_stock_price)
inputs=inputs.reshape(-1,1)
print(inputs.shape)
X_test=[]
for i in range(60, 61):
    X_test.append(inputs[test:i+test,0])
# make list to array
X_test = np.array(X_test)
X_test = np.reshape(X_test,(X_test.shape[0], X_test.shape[1],1))
predicted_stock_price = regressor.predict(X_test)
inputs=np.delete(inputs,len(inputs)-1,axis=0)
inputs=np.append(inputs,predicted_stock_price)
inputs=inputs.reshape(-1,1)
print("currently running {}".format(test))

模型的實際預測應該如下圖所示在此處輸入圖片說明

但是對於上面的代碼,我得到了下圖在此處輸入圖片說明

你能告訴我我哪里出錯了嗎? 如果您需要更多詳細信息,請告訴我

您還沒有轉換回值。 預測值基於變換數據。

這應該有效:

predicted_stock_price_orig = inputs.inverse_transform(predicted_stock_price)

請參考這個問題以獲得更多幫助: scikit-learn: how to scale back the 'y'預測結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM