(kline_df, pred_df)
| 6 | |
| 7 | |
| 8 | def plot_prediction(kline_df, pred_df): |
| 9 | pred_df.index = kline_df.index[-pred_df.shape[0]:] |
| 10 | sr_close = kline_df['close'] |
| 11 | sr_pred_close = pred_df['close'] |
| 12 | sr_close.name = 'Ground Truth' |
| 13 | sr_pred_close.name = "Prediction" |
| 14 | |
| 15 | close_df = pd.concat([sr_close, sr_pred_close], axis=1) |
| 16 | |
| 17 | fig, ax = plt.subplots(1, 1, figsize=(8, 4)) |
| 18 | |
| 19 | ax.plot(close_df['Ground Truth'], label='Ground Truth', color='blue', linewidth=1.5) |
| 20 | ax.plot(close_df['Prediction'], label='Prediction', color='red', linewidth=1.5) |
| 21 | ax.set_ylabel('Close Price', fontsize=14) |
| 22 | ax.legend(loc='lower left', fontsize=12) |
| 23 | ax.grid(True) |
| 24 | |
| 25 | plt.tight_layout() |
| 26 | plt.show() |
| 27 | |
| 28 | |
| 29 | # 1. Load Model and Tokenizer |
no outgoing calls
no test coverage detected