Seaborn forecast gap

Viewed 18
  1. I have a dataframe with two columns 'Active' and 'Y' for year. Year period is 2010-2017 and it is indexed to period for forecasting

  2. I created a quadratic model with Deterministic Process, fit Active with the years with linear regression and forecasted 4 years. I have two output arrays indexed with the year from all this: y_pred for the in sample regression and y_fore for the out of sample regression.

  3. When I plot them with Seaborn there is a gap of one year between 2017 and 2018 This is the code:

    ax = y.plot(**plot_params, alpha=0.5, title="Active enterprises forecast", ylabel="Active") ax = y_pred.plot(ax=ax, linewidth=3, label="Trend", color='C0') ax = y_fore.plot(ax=ax, linewidth=3, label="Trend Forecast", color='C3') ax.legend();

  4. So I read this thread which was very helpful. Seaborn: How to handle gap between historic and forecasted values? and I added the value for 2017 to y_fore with

    y_fore.loc['2017-01-01']=35496.625000

The problem is that this method adds 2017 after 2021 which then makes the forecast plot a mess because the forecast line starts from 2018, proceeds to 2021 and then comes back to 2017.

What I've tried:

  1. to sort the indexed years of y_fore with sort. Fail: it returns an error that sort is not supported.
  2. to sort them with numpy argsort. Fail: the years get sorted but the values associated with the years disappear.

Any other suggestions?

It works just fine when I add the 2018 values of y_fore to y_pred. In reality I do not have the values for 2018 within the insample set y_pred.

0 Answers
Related