Spaces:
Running
Running
Commit
·
102b083
1
Parent(s):
0662fc3
Debug graphs
Browse files
app.py
CHANGED
@@ -179,19 +179,29 @@ def sales_growth(dataframe, fittedValues):
|
|
179 |
return sales_growth
|
180 |
|
181 |
@st.cache_data
|
182 |
-
def merge_forecast_data(actual, predicted, future):
|
183 |
actual = actual.to_frame()
|
184 |
actual.rename(columns={actual.columns[0]: "Actual Sales"}, inplace=True)
|
|
|
|
|
185 |
|
186 |
predicted = predicted.to_frame()
|
187 |
predicted.rename(columns={predicted.columns[0]: "Predicted Sales"}, inplace=True)
|
|
|
|
|
188 |
|
189 |
future = future.to_frame()
|
190 |
future = future.rename_axis('Date')
|
191 |
future.rename(columns={future.columns[0]: "Forecasted Future Sales"}, inplace=True)
|
|
|
|
|
192 |
|
193 |
merged_dataframe = pd.concat([actual, predicted, future], axis=1)
|
|
|
|
|
194 |
merged_dataframe = merged_dataframe.reset_index()
|
|
|
|
|
195 |
return merged_dataframe
|
196 |
|
197 |
@st.cache_data
|
@@ -353,8 +363,13 @@ if (st.session_state.uploaded):
|
|
353 |
|
354 |
col_charts = st.columns(2)
|
355 |
|
|
|
|
|
|
|
356 |
print(merged_data[merged_data.columns[0]]) # for debugging
|
|
|
357 |
print(merged_data_dates[merged_data.columns[0]]) # for debugging
|
|
|
358 |
min_date = merged_data_dates[merged_data_dates.columns[0]].min()
|
359 |
max_date = merged_data_dates[merged_data_dates.columns[0]].max()
|
360 |
with col_charts[0]:
|
@@ -363,11 +378,6 @@ if (st.session_state.uploaded):
|
|
363 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
364 |
fig_compare.update_layout(title='Historical Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
365 |
# fig_compare.update_xaxes(range=[min_date, max_date])
|
366 |
-
fig_compare.update_layout(
|
367 |
-
xaxis=dict(
|
368 |
-
range=[min_date, max_date] # Set the range of x-axis
|
369 |
-
)
|
370 |
-
)
|
371 |
st.plotly_chart(fig_compare, use_container_width=True)
|
372 |
|
373 |
with col_charts[1]:
|
@@ -377,11 +387,6 @@ if (st.session_state.uploaded):
|
|
377 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Sales'], mode='lines', name='Forecasted Sales', line=dict(color=mape_color)))
|
378 |
fig_forecast.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
379 |
# fig_forecast.update_xaxes(range=[min_date, max_date])
|
380 |
-
fig_forecast.update_layout(
|
381 |
-
xaxis=dict(
|
382 |
-
range=[min_date, max_date] # Set the range of x-axis
|
383 |
-
)
|
384 |
-
)
|
385 |
st.plotly_chart(fig_forecast, use_container_width=True)
|
386 |
st.write(f"MAPE score: {mape}% - {interpretation}")
|
387 |
|
|
|
179 |
return sales_growth
|
180 |
|
181 |
@st.cache_data
|
182 |
+
def merge_forecast_data(actual, predicted, future): # debug
|
183 |
actual = actual.to_frame()
|
184 |
actual.rename(columns={actual.columns[0]: "Actual Sales"}, inplace=True)
|
185 |
+
print("ACTUAL")
|
186 |
+
print(actual)
|
187 |
|
188 |
predicted = predicted.to_frame()
|
189 |
predicted.rename(columns={predicted.columns[0]: "Predicted Sales"}, inplace=True)
|
190 |
+
print("PREDICTED")
|
191 |
+
print(predicted)
|
192 |
|
193 |
future = future.to_frame()
|
194 |
future = future.rename_axis('Date')
|
195 |
future.rename(columns={future.columns[0]: "Forecasted Future Sales"}, inplace=True)
|
196 |
+
print("FUTURE")
|
197 |
+
print(future)
|
198 |
|
199 |
merged_dataframe = pd.concat([actual, predicted, future], axis=1)
|
200 |
+
print("MERGED DATAFRAME")
|
201 |
+
print(merged_dataframe)
|
202 |
merged_dataframe = merged_dataframe.reset_index()
|
203 |
+
print("MERGED DATAFRAME RESET INDEX")
|
204 |
+
print(merged_dataframe)
|
205 |
return merged_dataframe
|
206 |
|
207 |
@st.cache_data
|
|
|
363 |
|
364 |
col_charts = st.columns(2)
|
365 |
|
366 |
+
print(merged_data)
|
367 |
+
print(merged_data.info)
|
368 |
+
print(merged_data.dtypes)
|
369 |
print(merged_data[merged_data.columns[0]]) # for debugging
|
370 |
+
print(merged_data[merged_data.columns[0]].info) # for debugging
|
371 |
print(merged_data_dates[merged_data.columns[0]]) # for debugging
|
372 |
+
print(merged_data_dates.info)
|
373 |
min_date = merged_data_dates[merged_data_dates.columns[0]].min()
|
374 |
max_date = merged_data_dates[merged_data_dates.columns[0]].max()
|
375 |
with col_charts[0]:
|
|
|
378 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
379 |
fig_compare.update_layout(title='Historical Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
380 |
# fig_compare.update_xaxes(range=[min_date, max_date])
|
|
|
|
|
|
|
|
|
|
|
381 |
st.plotly_chart(fig_compare, use_container_width=True)
|
382 |
|
383 |
with col_charts[1]:
|
|
|
387 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Sales'], mode='lines', name='Forecasted Sales', line=dict(color=mape_color)))
|
388 |
fig_forecast.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
389 |
# fig_forecast.update_xaxes(range=[min_date, max_date])
|
|
|
|
|
|
|
|
|
|
|
390 |
st.plotly_chart(fig_forecast, use_container_width=True)
|
391 |
st.write(f"MAPE score: {mape}% - {interpretation}")
|
392 |
|