Forecasting : FB Prophet function doesn't start from last datapoint in python

2 days ago 5
ARTICLE AD BOX

I've noticed that Facebook's Prophet function does a good job with forecasting. However, for my data, it never starts at the last value of y-predict. As you can see in the image, the last value of Total_Issues is 168, but the function predicts that the next value is 143.

Is there a way to enable a "cumulative" option so that the predictions never decrease in value?

graph (actual into predicted)

df.set_index('Creation_date', inplace=True) pd.to_datetime(df.index) ### Create one issue per row df["Total_Issues"] = range(len(df)) df["Total_Issues"] = df["Total_Issues"] + 1 ### Drops duplicate date values so we can create a time series df = df.loc[~df.index.duplicated(keep='last'), :] print("Removed duplicated dates") print(df) ## Only Select the columns we need df = df.loc[:,["Total_Issues"]] ## Fill empty dates so we get a full time series df = df.resample('D').bfill() ### Predict Future ### horizon = 180 forecast_df = df['Total_Issues'] last_date = forecast_df.index.max() forecaster = Prophet() forecaster.fit(forecast_df) fh = ForecastingHorizon( pd.date_range(str(last_date), freq="D", periods = horizon), is_relative=False ) ## Create prediction y_pred = forecaster.predict(fh) ## Create confidence interval ci = forecaster.predict_interval(fh, coverage=0.9) ## Plot plt.show() plt.plot( forecast_df.tail(horizon*3), label="Actual", color="black" ) plt.gca().fill_between( ci.index, (ci.iloc[:,0]), (ci.iloc[:,1]), alpha=0.1, ) plt.plot(y_pred, label="Predicted") plt.ylim(bottom=0) plt.legend() plt.show()
Read Entire Article