Spaces:
Running
Running
Circhastic
commited on
Commit
•
4d681bd
1
Parent(s):
33ff941
Version 1 hotfix #29 for merge
Browse files
app.py
CHANGED
@@ -196,15 +196,15 @@ def merge_forecast_data(actual, predicted, future):
|
|
196 |
|
197 |
@st.cache_data
|
198 |
def interpret_mape(mape_score):
|
199 |
-
score = mape_score * 100
|
200 |
if score < 10:
|
201 |
-
interpretation = "
|
202 |
elif score < 20:
|
203 |
-
interpretation = "Good
|
204 |
elif score < 50:
|
205 |
-
interpretation = "
|
206 |
else:
|
207 |
-
interpretation = "
|
208 |
return score, interpretation
|
209 |
|
210 |
# TAPAS Model
|
@@ -336,22 +336,6 @@ if (st.session_state.uploaded):
|
|
336 |
future_lower_series = pd.Series(confint[:, 0], index=future_index_of_fc)
|
337 |
future_upper_series = pd.Series(confint[:, 1], index=future_index_of_fc)
|
338 |
|
339 |
-
# Plot
|
340 |
-
# plt.plot(df['Sales'], color='b', label = 'Actual Sales')
|
341 |
-
# plt.plot(test_y, color='b')
|
342 |
-
# plt.plot(fitted_series, color='r', label = 'Predicted Sales')
|
343 |
-
# plt.title("SARIMAX - Forecast of Auto Business Retail Sales VS Actual Sales")
|
344 |
-
# plt.legend(loc='upper left', fontsize=8)
|
345 |
-
# plt.plot(future_fitted_series, color='darkgreen', label ='Future Forecasted Sales')
|
346 |
-
# plt.fill_between(future_lower_series.index,
|
347 |
-
# future_lower_series,
|
348 |
-
# future_upper_series,
|
349 |
-
# color='k', alpha=.15)
|
350 |
-
# plt.fill_between(lower_series.index,
|
351 |
-
# lower_series,
|
352 |
-
# upper_series,
|
353 |
-
# color='k', alpha=.15)
|
354 |
-
|
355 |
future_sales_growth = sales_growth(df, future_fitted_series)
|
356 |
future_sales_growth = future_sales_growth.iloc[n_periods:]
|
357 |
df = dates_df(future_sales_growth)
|
@@ -365,11 +349,11 @@ if (st.session_state.uploaded):
|
|
365 |
merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
|
366 |
|
367 |
fig = go.Figure()
|
368 |
-
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=
|
369 |
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
370 |
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Future Sales'], mode='lines', name='Forecasted Future Sales'))
|
371 |
fig.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
372 |
-
fig.update_xaxes(range=['
|
373 |
col[0].plotly_chart(fig)
|
374 |
col[0].write(f"MAPE score: {mape}% - {interpretation}")
|
375 |
with col[1]:
|
|
|
196 |
|
197 |
@st.cache_data
|
198 |
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 |
return score, interpretation
|
209 |
|
210 |
# TAPAS Model
|
|
|
336 |
future_lower_series = pd.Series(confint[:, 0], index=future_index_of_fc)
|
337 |
future_upper_series = pd.Series(confint[:, 1], index=future_index_of_fc)
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
future_sales_growth = sales_growth(df, future_fitted_series)
|
340 |
future_sales_growth = future_sales_growth.iloc[n_periods:]
|
341 |
df = dates_df(future_sales_growth)
|
|
|
349 |
merged_data = merge_forecast_data(df['Sales'], fitted_series, future_fitted_series)
|
350 |
|
351 |
fig = go.Figure()
|
352 |
+
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=df['Sales'].to_frame(), mode='lines', name='Actual Sales'))
|
353 |
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Predicted Sales'], mode='lines', name='Predicted Sales'))
|
354 |
fig.add_trace(go.Scatter(x=merged_data[merged_data.columns[0]], y=merged_data['Forecasted Future Sales'], mode='lines', name='Forecasted Future Sales'))
|
355 |
fig.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
356 |
+
fig.update_xaxes(range=['2020-01-01', '2025-01-01']) # TODO: Change this to be adaptive
|
357 |
col[0].plotly_chart(fig)
|
358 |
col[0].write(f"MAPE score: {mape}% - {interpretation}")
|
359 |
with col[1]:
|