Spaces:
Running
Running
Circhastic
commited on
Commit
•
2b2d52f
1
Parent(s):
c3fa8df
Fix app graphs
Browse files
app.py
CHANGED
@@ -344,19 +344,25 @@ if (st.session_state.uploaded):
|
|
344 |
mape, interpretation = interpret_mape(score['mape'])
|
345 |
|
346 |
merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
|
347 |
-
|
|
|
348 |
|
349 |
col_charts = st.columns(2)
|
350 |
-
|
351 |
-
|
352 |
-
|
|
|
353 |
with col_charts[0]:
|
354 |
fig_compare = go.Figure()
|
355 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Actual Sales'], mode='lines', name='Actual Sales'))
|
356 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
357 |
fig_compare.update_layout(title='Historical Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
358 |
-
fig_compare.update_xaxes(range=[
|
359 |
-
fig_compare.
|
|
|
|
|
|
|
|
|
360 |
st.plotly_chart(fig_compare, use_container_width=True)
|
361 |
|
362 |
with col_charts[1]:
|
@@ -364,8 +370,13 @@ if (st.session_state.uploaded):
|
|
364 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Actual Sales'], mode='lines', name='Actual Sales'))
|
365 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Future Sales'], mode='lines', name='Forecasted Future Sales'))
|
366 |
fig_forecast.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
367 |
-
fig_forecast.update_xaxes(range=[min_date, max_date])
|
368 |
-
|
|
|
|
|
|
|
|
|
|
|
369 |
st.write(f"MAPE score: {mape}% - {interpretation}")
|
370 |
|
371 |
col_table = st.columns(2)
|
|
|
344 |
mape, interpretation = interpret_mape(score['mape'])
|
345 |
|
346 |
merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
|
347 |
+
merged_data_dates = merged_data.copy()
|
348 |
+
merged_data_dates[merged_data_dates.columns[0]] = pd.to_datetime(merged_data_dates[merged_data_dates.columns[0]])
|
349 |
|
350 |
col_charts = st.columns(2)
|
351 |
+
|
352 |
+
print(merged_data_dates[merged_data.columns[0]]) # for debugging
|
353 |
+
min_date = merged_data_dates[merged_data_dates.columns[0]].min()
|
354 |
+
max_date = merged_data_dates[merged_data_dates.columns[0]].max()
|
355 |
with col_charts[0]:
|
356 |
fig_compare = go.Figure()
|
357 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Actual Sales'], mode='lines', name='Actual Sales'))
|
358 |
fig_compare.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
359 |
fig_compare.update_layout(title='Historical Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
360 |
+
# fig_compare.update_xaxes(range=[min_date, max_date])
|
361 |
+
fig_compare.update_layout(
|
362 |
+
xaxis=dict(
|
363 |
+
range=[min_date, max_date] # Set the range of x-axis
|
364 |
+
)
|
365 |
+
)
|
366 |
st.plotly_chart(fig_compare, use_container_width=True)
|
367 |
|
368 |
with col_charts[1]:
|
|
|
370 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Actual Sales'], mode='lines', name='Actual Sales'))
|
371 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Future Sales'], mode='lines', name='Forecasted Future Sales'))
|
372 |
fig_forecast.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
373 |
+
# fig_forecast.update_xaxes(range=[min_date, max_date])
|
374 |
+
fig_forecast.update_layout(
|
375 |
+
xaxis=dict(
|
376 |
+
range=[min_date, max_date] # Set the range of x-axis
|
377 |
+
)
|
378 |
+
)
|
379 |
+
st.plotly_chart(fig_forecast, use_container_width=True)
|
380 |
st.write(f"MAPE score: {mape}% - {interpretation}")
|
381 |
|
382 |
col_table = st.columns(2)
|