Prajwal3009 commited on
Commit
cb09aff
·
verified ·
1 Parent(s): e6a8020

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -33
app.py CHANGED
@@ -54,13 +54,14 @@ if st.button("Forecast"):
54
  st.write(st.session_state.arima_forecast)
55
 
56
  # Plot ARIMA results
57
- plt.figure(figsize=(10, 6))
58
- plt.plot(st.session_state.arima_forecast, label='ARIMA Forecast', color='blue')
59
- plt.title(f'ARIMA Forecast for Product {selected_product}')
60
- plt.xlabel('Weeks')
61
- plt.ylabel('Sales Quantity')
62
- plt.legend()
63
- st.pyplot()
 
64
 
65
  elif model_option == "Decision Tree":
66
  # Load Decision Tree model
@@ -76,13 +77,14 @@ if st.button("Forecast"):
76
  st.write(st.session_state.dt_forecast)
77
 
78
  # Plot Decision Tree results
79
- plt.figure(figsize=(10, 6))
80
- plt.plot(st.session_state.dt_forecast, label='Decision Tree Forecast', color='green')
81
- plt.title(f'Decision Tree Forecast for Product {selected_product}')
82
- plt.xlabel('Weeks')
83
- plt.ylabel('Sales Quantity')
84
- plt.legend()
85
- st.pyplot()
 
86
 
87
  elif model_option == "XGBoost":
88
  # Load XGBoost model
@@ -98,13 +100,14 @@ if st.button("Forecast"):
98
  st.write(st.session_state.xgb_forecast)
99
 
100
  # Plot XGBoost results
101
- plt.figure(figsize=(10, 6))
102
- plt.plot(st.session_state.xgb_forecast, label='XGBoost Forecast', color='orange')
103
- plt.title(f'XGBoost Forecast for Product {selected_product}')
104
- plt.xlabel('Weeks')
105
- plt.ylabel('Sales Quantity')
106
- plt.legend()
107
- st.pyplot()
 
108
 
109
  # Comparison button
110
  if st.button("Compare Models"):
@@ -136,23 +139,24 @@ if st.button("Compare Models"):
136
  st.session_state.xgb_forecast = xgb_model.predict(future_data)
137
 
138
  # Now plot all the forecasts
139
- plt.figure(figsize=(10, 6))
140
 
141
  # ARIMA forecast
142
  if st.session_state.arima_forecast is not None:
143
- plt.plot(st.session_state.arima_forecast, label='ARIMA Forecast', color='blue')
144
-
145
  # Decision Tree forecast
146
  if st.session_state.dt_forecast is not None:
147
- plt.plot(st.session_state.dt_forecast, label='Decision Tree Forecast', color='green')
148
-
149
  # XGBoost forecast
150
  if st.session_state.xgb_forecast is not None:
151
- plt.plot(st.session_state.xgb_forecast, label='XGBoost Forecast', color='orange')
152
-
153
- plt.title(f'Comparison of Forecasts for Product {selected_product}')
154
- plt.xlabel('Weeks')
155
- plt.ylabel('Sales Quantity')
156
- plt.legend()
157
- st.pyplot()
 
158
 
 
54
  st.write(st.session_state.arima_forecast)
55
 
56
  # Plot ARIMA results
57
+ fig, ax = plt.subplots(figsize=(10, 6))
58
+ ax.plot(st.session_state.arima_forecast, label='ARIMA Forecast', color='blue')
59
+ ax.set_title(f'ARIMA Forecast for Product {selected_product}')
60
+ ax.set_xlabel('Weeks')
61
+ ax.set_ylabel('Sales Quantity')
62
+ ax.legend()
63
+
64
+ st.pyplot(fig)
65
 
66
  elif model_option == "Decision Tree":
67
  # Load Decision Tree model
 
77
  st.write(st.session_state.dt_forecast)
78
 
79
  # Plot Decision Tree results
80
+ fig, ax = plt.subplots(figsize=(10, 6))
81
+ ax.plot(st.session_state.dt_forecast, label='Decision Tree Forecast', color='green')
82
+ ax.set_title(f'Decision Tree Forecast for Product {selected_product}')
83
+ ax.set_xlabel('Weeks')
84
+ ax.set_ylabel('Sales Quantity')
85
+ ax.legend()
86
+
87
+ st.pyplot(fig)
88
 
89
  elif model_option == "XGBoost":
90
  # Load XGBoost model
 
100
  st.write(st.session_state.xgb_forecast)
101
 
102
  # Plot XGBoost results
103
+ fig, ax = plt.subplots(figsize=(10, 6))
104
+ ax.plot(st.session_state.xgb_forecast, label='XGBoost Forecast', color='orange')
105
+ ax.set_title(f'XGBoost Forecast for Product {selected_product}')
106
+ ax.set_xlabel('Weeks')
107
+ ax.set_ylabel('Sales Quantity')
108
+ ax.legend()
109
+
110
+ st.pyplot(fig)
111
 
112
  # Comparison button
113
  if st.button("Compare Models"):
 
139
  st.session_state.xgb_forecast = xgb_model.predict(future_data)
140
 
141
  # Now plot all the forecasts
142
+ fig, ax = plt.subplots(figsize=(10, 6))
143
 
144
  # ARIMA forecast
145
  if st.session_state.arima_forecast is not None:
146
+ ax.plot(st.session_state.arima_forecast, label='ARIMA Forecast', color='blue')
147
+
148
  # Decision Tree forecast
149
  if st.session_state.dt_forecast is not None:
150
+ ax.plot(st.session_state.dt_forecast, label='Decision Tree Forecast', color='green')
151
+
152
  # XGBoost forecast
153
  if st.session_state.xgb_forecast is not None:
154
+ ax.plot(st.session_state.xgb_forecast, label='XGBoost Forecast', color='orange')
155
+
156
+ ax.set_title(f'Comparison of Forecasts for Product {selected_product}')
157
+ ax.set_xlabel('Weeks')
158
+ ax.set_ylabel('Sales Quantity')
159
+ ax.legend()
160
+
161
+ st.pyplot(fig)
162