Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 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.
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
| 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.
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
| 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.
|
| 140 |
|
| 141 |
# ARIMA forecast
|
| 142 |
if st.session_state.arima_forecast is not None:
|
| 143 |
-
|
| 144 |
-
|
| 145 |
# Decision Tree forecast
|
| 146 |
if st.session_state.dt_forecast is not None:
|
| 147 |
-
|
| 148 |
-
|
| 149 |
# XGBoost forecast
|
| 150 |
if st.session_state.xgb_forecast is not None:
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
| 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 |
|