yougandar commited on
Commit
7fbdb10
·
verified ·
1 Parent(s): 95f115b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -47,14 +47,11 @@ def plot_stock_data(df, forecast):
47
  # Plot historical data
48
  plt.plot(df['Date'], df['Close'], label='Historical', color='blue')
49
 
50
- # Align predicted data by combining historical and future dates
51
- combined_dates = pd.concat([df['Date'], forecast['ds']]).drop_duplicates()
52
 
53
- # Append the predicted values starting from the last historical date onwards
54
- predicted_values = pd.concat([pd.Series([None] * len(df)), forecast['yhat1'].iloc[len(df):]]).reset_index(drop=True)
55
-
56
- # Plot predicted data
57
- plt.plot(combined_dates, predicted_values, label='Predicted', linestyle='--', color='red')
58
 
59
  plt.xlabel('Date')
60
  plt.ylabel('Stock Price')
 
47
  # Plot historical data
48
  plt.plot(df['Date'], df['Close'], label='Historical', color='blue')
49
 
50
+ # Plot predicted data only for the future dates (after the last date of historical data)
51
+ forecast_future = forecast[forecast['ds'] > df['Date'].max()]
52
 
53
+ # Plot predicted future data
54
+ plt.plot(forecast_future['ds'], forecast_future['yhat1'], label='Predicted', linestyle='--', color='red')
 
 
 
55
 
56
  plt.xlabel('Date')
57
  plt.ylabel('Stock Price')