Spaces:
Runtime error
Runtime error
added 0 price change scenario
Browse files- app.py +1 -1
- get_forecast.py +8 -1
app.py
CHANGED
@@ -19,7 +19,7 @@ with gr.Blocks() as demo:
|
|
19 |
with gr.Row():
|
20 |
serie = gr.Dropdown(choices = ['SOM', 'Volumen'], value = 'SOM', label = 'Serie', info = 'Choose the serie to forecast')
|
21 |
periods = gr.Slider(minimum = 1, maximum = 12, step = 1, value = 3, label = 'Months', info = 'How many months to forecast')
|
22 |
-
percent_change = gr.Slider(minimum = -100, maximum = 100, step = 5, value = -5, label = 'Price
|
23 |
|
24 |
with gr.Row():
|
25 |
dataframe = gr.Dataframe(label = 'Predicted values')
|
|
|
19 |
with gr.Row():
|
20 |
serie = gr.Dropdown(choices = ['SOM', 'Volumen'], value = 'SOM', label = 'Serie', info = 'Choose the serie to forecast')
|
21 |
periods = gr.Slider(minimum = 1, maximum = 12, step = 1, value = 3, label = 'Months', info = 'How many months to forecast')
|
22 |
+
percent_change = gr.Slider(minimum = -100, maximum = 100, step = 5, value = -5, label = 'Price change', info = "Price change vs last year (%)")
|
23 |
|
24 |
with gr.Row():
|
25 |
dataframe = gr.Dataframe(label = 'Predicted values')
|
get_forecast.py
CHANGED
@@ -44,11 +44,18 @@ def get_forecast(serie: str, periods, percent_change: int):
|
|
44 |
# aux to plot
|
45 |
last_obs = history.iloc[-1:][['ds', 'y']].rename(columns = {'y': 'yhat'})
|
46 |
future_aux = pd.concat([last_obs, future_values])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# plot
|
49 |
fig = plt.figure()
|
50 |
-
#plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
|
51 |
plt.plot(future_aux['ds'], future_aux['yhat'], label = 'Forecast', marker = '.', color = 'C1')
|
|
|
52 |
plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
|
53 |
plt.xticks(rotation = 45)
|
54 |
#plt.xlabel('Date')
|
|
|
44 |
# aux to plot
|
45 |
last_obs = history.iloc[-1:][['ds', 'y']].rename(columns = {'y': 'yhat'})
|
46 |
future_aux = pd.concat([last_obs, future_values])
|
47 |
+
|
48 |
+
# 0 price change scenario
|
49 |
+
future_0 = future.copy()
|
50 |
+
future_0['precio_hl'] = past_prices
|
51 |
+
forecast_0 = model.predict(future_0)
|
52 |
+
values_0 = forecast_0[['ds', 'yhat']]
|
53 |
+
aux_0 = pd.concat([last_obs, values_0])
|
54 |
|
55 |
# plot
|
56 |
fig = plt.figure()
|
|
|
57 |
plt.plot(future_aux['ds'], future_aux['yhat'], label = 'Forecast', marker = '.', color = 'C1')
|
58 |
+
plt.plot(aux_0['ds'], aux_0['yhat'], label = 'No change', marker = '.', color = 'C2')
|
59 |
plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
|
60 |
plt.xticks(rotation = 45)
|
61 |
#plt.xlabel('Date')
|