両建て手法の開発②

目標

close, high, low を予測し、同一グラフ内にプロットする

  1. closeを予測し、df変換後json形式に変換。

  2. 任意のdriveに保存

  3. high, close 共に同手順で保存

  4. close, high, low を呼び出し、matplot.libで描画

  5. 実際のcloseと予想したhigh, low を見て、提案する手法に優位性があるかどうかを検討する。

作業

closeを予測し、df変換後json形式に変換する

以下、作業結果コード

xpppp.hatenablog.com

# テストデータを使って予測&プロット
fig, ax1 = plt.subplots(1,1)
ax1.plot(df[df['time']>= split_date]['time'][window_len:],
         test['close'][window_len:], label='Actual', color='blue')
ax1.plot(df[df['time']>= split_date]['time'][window_len:],
         ((np.transpose(yen_model.predict(test_lstm_in))+1) * test['close'].values[:-window_len])[0], 
         label='Predicted', color='red')
ax1.grid(True)

f:id:xpppp:20191111202325p:plain

#np形式でcloseの予想値を表示
pred_close = ((np.transpose(yen_model.predict(test_lstm_in))+1) * test['close'].values[:-window_len])[0]
pred_close
#列名を設定
pred_close.columns = ['close']
pred_close.head()

jsonの書き出しには “Python jsonファイルを新規作成して書き込む”を参照