stinoco commited on
Commit
23a5a30
·
1 Parent(s): 8566ffe

changed labels

Browse files
Files changed (1) hide show
  1. 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 price change'] = values_0.rename(columns = {'ds': 'Date', 'yhat': serie})[serie]
54
- df_future['Diff'] = df_future[f'{serie} with price change'] - df_future[f'{serie} without price change']
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 price change'] = df_future[f'{serie} without price 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 Change Forecast', marker = '.', color = 'C1')
62
- plt.plot(aux_0['ds'], aux_0['yhat'], label = 'No Price 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)
 
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)