2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

prophet で株価予測メモ

Last updated at Posted at 2021-09-13

FB社が公開している時系列予測ツール prophet を使うと、今後の株価の動きが予測できるそうです。使い方のメモ。 Google Colaboratoryで実行できます。

インストルール

!pip install prophet

株価データの準備

stooq から取得

import pandas_datareader.data as pdr

df = pdr.DataReader("{}.JP".format(2929), "stooq").sort_index()
df.tail()

スクリーンショット 2021-09-13 12.15.32.png

分析用に加工

prophet で分析するために ds:日付, y:終値のカラムを設ける

df["ds"] = df.index
df = df.rename(columns={'Close': 'y'})
df.tail()

スクリーンショット 2021-09-13 12.17.45.png

分析実行

from prophet import Prophet

m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=365)
forecast = m.predict(future)
fig = m.plot(forecast)

スクリーンショット 2021-09-13 12.26.36.png

2021-09-10 以降のグラフが予想結果

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?