Spaces:
Running
Running
Circhastic
commited on
Commit
•
0662fc3
1
Parent(s):
2b2d52f
Fix app graph colors and debug
Browse files
app.py
CHANGED
@@ -199,13 +199,17 @@ def interpret_mape(mape_score):
|
|
199 |
score = (mape_score * 100).round(2)
|
200 |
if score < 10:
|
201 |
interpretation = "Great"
|
|
|
202 |
elif score < 20:
|
203 |
interpretation = "Good"
|
|
|
204 |
elif score < 50:
|
205 |
interpretation = "Relatively good"
|
|
|
206 |
else:
|
207 |
interpretation = "Poor"
|
208 |
-
|
|
|
209 |
|
210 |
# TAPAS Model
|
211 |
|
@@ -341,7 +345,7 @@ if (st.session_state.uploaded):
|
|
341 |
|
342 |
test_y, predictions = np.array(test_y), np.array(fitted)
|
343 |
score = forecast_accuracy(predictions, test_y)
|
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()
|
@@ -349,6 +353,7 @@ if (st.session_state.uploaded):
|
|
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()
|
@@ -369,6 +374,7 @@ if (st.session_state.uploaded):
|
|
369 |
fig_forecast = go.Figure()
|
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(
|
|
|
199 |
score = (mape_score * 100).round(2)
|
200 |
if score < 10:
|
201 |
interpretation = "Great"
|
202 |
+
color = "green"
|
203 |
elif score < 20:
|
204 |
interpretation = "Good"
|
205 |
+
color = "seagreen"
|
206 |
elif score < 50:
|
207 |
interpretation = "Relatively good"
|
208 |
+
color = "orange"
|
209 |
else:
|
210 |
interpretation = "Poor"
|
211 |
+
color = "red"
|
212 |
+
return score, interpretation, color
|
213 |
|
214 |
# TAPAS Model
|
215 |
|
|
|
345 |
|
346 |
test_y, predictions = np.array(test_y), np.array(fitted)
|
347 |
score = forecast_accuracy(predictions, test_y)
|
348 |
+
mape, interpretation, mape_color = interpret_mape(score['mape'])
|
349 |
|
350 |
merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
|
351 |
merged_data_dates = merged_data.copy()
|
|
|
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()
|
|
|
374 |
fig_forecast = go.Figure()
|
375 |
fig_forecast.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Actual Sales'], mode='lines', name='Actual Sales'))
|
376 |
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'))
|
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(
|