Spaces:
Runtime error
Runtime error
changed labels
Browse files- get_forecast.py +7 -7
get_forecast.py
CHANGED
@@ -48,18 +48,18 @@ def get_forecast(serie: str, periods, percent_change: int):
|
|
48 |
aux_0 = pd.concat([last_obs, values_0])
|
49 |
|
50 |
# arrange dataframe
|
51 |
-
df_future = future_values.rename(columns = {'ds': 'Date', 'yhat': f'{serie} with price change'}).copy()
|
52 |
df_future['Date'] = df_future['Date'].apply(lambda x: x.date())
|
53 |
-
df_future[f'{serie} without
|
54 |
-
df_future['Diff'] = df_future[f'{serie} with price change'] - df_future[f'{serie} without
|
55 |
-
df_future[f'{serie} with price change'] = df_future[f'{serie} with price change'].apply(lambda x: round(x, 4))
|
56 |
-
df_future[f'{serie} without
|
57 |
df_future['Diff'] = df_future['Diff'].apply(lambda x: round(x, 4))
|
58 |
|
59 |
# plot
|
60 |
fig = plt.figure()
|
61 |
-
plt.plot(future_aux['ds'], future_aux['yhat'], label = 'Price Change Forecast', marker = '.', color = 'C1')
|
62 |
-
plt.plot(aux_0['ds'], aux_0['yhat'], label = 'No
|
63 |
plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
|
64 |
plt.xticks(rotation = 45)
|
65 |
plt.ylabel(serie)
|
|
|
48 |
aux_0 = pd.concat([last_obs, values_0])
|
49 |
|
50 |
# arrange dataframe
|
51 |
+
df_future = future_values.rename(columns = {'ds': 'Date', 'yhat': f'{serie} with price policy change'}).copy()
|
52 |
df_future['Date'] = df_future['Date'].apply(lambda x: x.date())
|
53 |
+
df_future[f'{serie} without policy change'] = values_0.rename(columns = {'ds': 'Date', 'yhat': serie})[serie]
|
54 |
+
df_future['Diff'] = df_future[f'{serie} with price policy change'] - df_future[f'{serie} without policy change']
|
55 |
+
df_future[f'{serie} with price policy change'] = df_future[f'{serie} with price policy change'].apply(lambda x: round(x, 4))
|
56 |
+
df_future[f'{serie} without policy change'] = df_future[f'{serie} without policy change'].apply(lambda x: round(x, 4))
|
57 |
df_future['Diff'] = df_future['Diff'].apply(lambda x: round(x, 4))
|
58 |
|
59 |
# plot
|
60 |
fig = plt.figure()
|
61 |
+
plt.plot(future_aux['ds'], future_aux['yhat'], label = 'Price Policy Change Forecast', marker = '.', color = 'C1')
|
62 |
+
plt.plot(aux_0['ds'], aux_0['yhat'], label = 'No Policy Change Forecast', marker = '.', color = 'C2')
|
63 |
plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
|
64 |
plt.xticks(rotation = 45)
|
65 |
plt.ylabel(serie)
|