iT邦幫忙

0

[Day24]使用stocker套件進行預測(二)

  • 分享至 

  • xImage
  •  

導入stocker:
from stocker import Stocker
https://ithelp.ithome.com.tw/upload/images/20221120/201532349I4L8g5j8p.jpg
出現錯誤:No module named 'quandl'
解決辦法:
先進入anaconda prompt
https://ithelp.ithome.com.tw/upload/images/20221121/20153234vKtMVqXkSU.jpg
輸入conda install quandl按下Enter就會開始下載
https://ithelp.ithome.com.tw/upload/images/20221121/2015323477PhMoXg1c.jpg
若想測試是否安裝成功,可以去spyder輸入import quandl
https://ithelp.ithome.com.tw/upload/images/20221121/20153234lqykdAAw5b.jpg
沒有錯誤訊息就是下載成功

接著發現又出現錯誤:No module named 'fbprophet'
https://ithelp.ithome.com.tw/upload/images/20221121/20153234eyJDQPGV5L.jpg
解決方法:
我上網找了很多下載fbprophet的方法
試了很多方法結果都不成功.......
https://blog.51cto.com/u_15677788/5368619

例如跟著以上步驟下載fbprophet
https://ithelp.ithome.com.tw/upload/images/20221121/20153234AZ8DU8yIR8.jpg
缺少什麼module就下載

再來我們要將股價的資料讀取進去
import pandas as pd
df=pd.read_csv('price2330.csv',index_col='date',parse_dates=['date'])
price=df.squeeze()
price.head()
https://ithelp.ithome.com.tw/upload/images/20221121/2015323440sUnjMh5w.jpg
確定資料格式沒有問題後,讀取價格資料放進一個變數中
https://ithelp.ithome.com.tw/upload/images/20221121/201532340Q6OuZPyuY.jpg
確定時間沒問題後就可以開始預測了(fbprophet還是搞不定......)
https://ithelp.ithome.com.tw/upload/images/20221121/20153234zkJF7nRSVV.jpg
最後預測股價的程式碼打上去就大功告成
//days代表預測幾天後的股價
https://ithelp.ithome.com.tw/upload/images/20221121/201532346E8VfSsd4w.jpg
成品會像上圖那樣子

PS:日後會想辦法把fbprophet搞定,做出完成品


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言