stinoco commited on
Commit
4d1aec1
·
1 Parent(s): 630939d

changed labels

Browse files
Files changed (1) hide show
  1. get_forecast.py +5 -6
get_forecast.py CHANGED
@@ -50,19 +50,18 @@ def get_forecast(serie: str, periods, percent_change: int):
50
  # arrange dataframe
51
  df_future = future_values.rename(columns = {'ds': 'Date', 'yhat': serie}).copy()
52
  df_future['Date'] = df_future['Date'].apply(lambda x: x.date())
53
- df_future[f'No change {serie}'] = values_0.rename(columns = {'ds': 'Date', 'yhat': serie})[serie]
54
- df_future['Diff'] = df_future[serie] - df_future[f'No change {serie}']
55
  df_future[serie] = df_future[serie].apply(lambda x: round(x, 4))
56
- df_future[f'No change {serie}'] = df_future[f'No change {serie}'].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 = 'Forecast', marker = '.', color = 'C1')
62
- plt.plot(aux_0['ds'], aux_0['yhat'], label = 'No change', marker = '.', color = 'C2')
63
  plt.plot(history['ds'], history['y'], label = 'Historic data', marker = '.', color = 'C0')
64
  plt.xticks(rotation = 45)
65
- #plt.xlabel('Date')
66
  plt.ylabel(serie)
67
  plt.tight_layout()
68
  plt.legend()
 
50
  # arrange dataframe
51
  df_future = future_values.rename(columns = {'ds': 'Date', 'yhat': serie}).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[serie] - df_future[f'{serie} without price change']
55
  df_future[serie] = df_future[serie].apply(lambda x: round(x, 4))
56
+ df_future[f'{serie} without prince 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 = 'Forecast with price change', marker = '.', color = 'C1')
62
+ plt.plot(aux_0['ds'], aux_0['yhat'], label = 'Forecast without price change', 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)
66
  plt.tight_layout()
67
  plt.legend()