Circhastic commited on
Commit
cc724c9
1 Parent(s): 60d1a78

Version 1 fix

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -181,6 +181,7 @@ def sales_growth(dataframe, fittedValues):
181
 
182
  @st.cache_data
183
  def merge_forecast_data(historical, test, future):
 
184
  historical.rename(columns={historical.columns[0]: "Actual Sales"}, inplace=True)
185
  test = test.to_frame()
186
  test.rename(columns={test.columns[0]: "Predicted Sales"}, inplace=True)
@@ -275,6 +276,7 @@ with st.sidebar:
275
  st.download_button("Download our sample CSV", f, file_name='sample.csv')
276
 
277
  if (st.session_state.uploaded):
 
278
  st.line_chart(series)
279
 
280
  MIN_DAYS = 30
@@ -305,12 +307,6 @@ if (st.session_state.uploaded):
305
  lower_series = pd.Series(confint[:, 0], index=index_of_fc)
306
  upper_series = pd.Series(confint[:, 1], index=index_of_fc)
307
 
308
- # plt.plot(df['Sales'], color='b', label = 'Actual Sales')
309
- # plt.plot(test_y, color='b')
310
- # plt.plot(fitted_series, color='r', label = 'Predicted Sales')
311
- # plt.title("SARIMAX - Forecast of Auto Business Retail Sales VS Actual Sales")
312
- # plt.legend(loc='upper left', fontsize=8)
313
-
314
  #Future predictions
315
  frequency = '3D'
316
  future_fitted, confint = train_test_model.predict(X=df.iloc[-future_n_periods:,1:], n_periods=future_n_periods, return_conf_int=True, freq=frequency)
@@ -322,7 +318,12 @@ if (st.session_state.uploaded):
322
  future_lower_series = pd.Series(confint[:, 0], index=future_index_of_fc)
323
  future_upper_series = pd.Series(confint[:, 1], index=future_index_of_fc)
324
 
325
- # TODO Plot Future
 
 
 
 
 
326
  # plt.plot(future_fitted_series, color='darkgreen', label ='Future Forecasted Sales')
327
  # plt.fill_between(future_lower_series.index,
328
  # future_lower_series,
@@ -343,7 +344,7 @@ if (st.session_state.uploaded):
343
  merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
344
  col[0].line_chart(merged_data)
345
  with col[1]:
346
- col[1].subheader("Forecasted sales in x days")
347
  col[1].write(df)
348
  st.session_state.forecasted = True
349
 
 
181
 
182
  @st.cache_data
183
  def merge_forecast_data(historical, test, future):
184
+ historical = historical.to_frame()
185
  historical.rename(columns={historical.columns[0]: "Actual Sales"}, inplace=True)
186
  test = test.to_frame()
187
  test.rename(columns={test.columns[0]: "Predicted Sales"}, inplace=True)
 
276
  st.download_button("Download our sample CSV", f, file_name='sample.csv')
277
 
278
  if (st.session_state.uploaded):
279
+ st.subheader("Sales History")
280
  st.line_chart(series)
281
 
282
  MIN_DAYS = 30
 
307
  lower_series = pd.Series(confint[:, 0], index=index_of_fc)
308
  upper_series = pd.Series(confint[:, 1], index=index_of_fc)
309
 
 
 
 
 
 
 
310
  #Future predictions
311
  frequency = '3D'
312
  future_fitted, confint = train_test_model.predict(X=df.iloc[-future_n_periods:,1:], n_periods=future_n_periods, return_conf_int=True, freq=frequency)
 
318
  future_lower_series = pd.Series(confint[:, 0], index=future_index_of_fc)
319
  future_upper_series = pd.Series(confint[:, 1], index=future_index_of_fc)
320
 
321
+ # Plot
322
+ # plt.plot(df['Sales'], color='b', label = 'Actual Sales')
323
+ # plt.plot(test_y, color='b')
324
+ # plt.plot(fitted_series, color='r', label = 'Predicted Sales')
325
+ # plt.title("SARIMAX - Forecast of Auto Business Retail Sales VS Actual Sales")
326
+ # plt.legend(loc='upper left', fontsize=8)
327
  # plt.plot(future_fitted_series, color='darkgreen', label ='Future Forecasted Sales')
328
  # plt.fill_between(future_lower_series.index,
329
  # future_lower_series,
 
344
  merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
345
  col[0].line_chart(merged_data)
346
  with col[1]:
347
+ col[1].subheader(f"Forecasted sales in the next {period} days")
348
  col[1].write(df)
349
  st.session_state.forecasted = True
350