Spaces:
Running
Running
Circhastic
commited on
Commit
·
6607488
1
Parent(s):
128493f
Version 1 hotfix #27 for merge
Browse files
app.py
CHANGED
|
@@ -195,16 +195,17 @@ def merge_forecast_data(actual, predicted, future):
|
|
| 195 |
return merged_dataframe
|
| 196 |
|
| 197 |
@st.cache_data
|
| 198 |
-
def interpret_mape(
|
| 199 |
-
|
| 200 |
-
if
|
| 201 |
-
|
| 202 |
-
elif
|
| 203 |
-
|
| 204 |
-
elif
|
| 205 |
-
|
| 206 |
else:
|
| 207 |
-
|
|
|
|
| 208 |
|
| 209 |
# TAPAS Model
|
| 210 |
|
|
@@ -356,8 +357,8 @@ if (st.session_state.uploaded):
|
|
| 356 |
df = dates_df(future_sales_growth)
|
| 357 |
|
| 358 |
test_y, predictions = np.array(test_y), np.array(fitted)
|
| 359 |
-
|
| 360 |
-
interpretation = interpret_mape(
|
| 361 |
|
| 362 |
col = st.columns(2)
|
| 363 |
with col[0]:
|
|
@@ -370,7 +371,7 @@ if (st.session_state.uploaded):
|
|
| 370 |
fig.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
| 371 |
fig.update_xaxes(range=['2018-01-01', '2026-01-01'])
|
| 372 |
col[0].plotly_chart(fig)
|
| 373 |
-
col[0].write(f"MAPE score: {
|
| 374 |
with col[1]:
|
| 375 |
col[1].subheader(f"Forecasted sales in the next {period} days")
|
| 376 |
col[1].write(df)
|
|
|
|
| 195 |
return merged_dataframe
|
| 196 |
|
| 197 |
@st.cache_data
|
| 198 |
+
def interpret_mape(mape):
|
| 199 |
+
mape = mape * 100
|
| 200 |
+
if mape < 10:
|
| 201 |
+
interpretation = "Highly Accurate"
|
| 202 |
+
elif mape < 20:
|
| 203 |
+
interpretation = "Good Accuracy"
|
| 204 |
+
elif mape < 50:
|
| 205 |
+
interpretation = "Reasonable Accuracy"
|
| 206 |
else:
|
| 207 |
+
interpretation = "Inaccurate"
|
| 208 |
+
return mape, interpretation
|
| 209 |
|
| 210 |
# TAPAS Model
|
| 211 |
|
|
|
|
| 357 |
df = dates_df(future_sales_growth)
|
| 358 |
|
| 359 |
test_y, predictions = np.array(test_y), np.array(fitted)
|
| 360 |
+
score = forecast_accuracy(predictions, test_y)
|
| 361 |
+
mape, interpretation = interpret_mape(score)
|
| 362 |
|
| 363 |
col = st.columns(2)
|
| 364 |
with col[0]:
|
|
|
|
| 371 |
fig.update_layout(title='Forecasted Sales Data', xaxis_title='Date', yaxis_title='Sales')
|
| 372 |
fig.update_xaxes(range=['2018-01-01', '2026-01-01'])
|
| 373 |
col[0].plotly_chart(fig)
|
| 374 |
+
col[0].write(f"MAPE score: {mape}% - {interpretation}")
|
| 375 |
with col[1]:
|
| 376 |
col[1].subheader(f"Forecasted sales in the next {period} days")
|
| 377 |
col[1].write(df)
|