luke14free / pm-prophet

GAM timeseries modeling with auto-changepoint detection. Inspired by Facebook Prophet and implemented in PyMC3
325 stars 42 forks source link

Non-Linear Forecasting with pm-prophet #21

Open BjornHartmann opened 4 years ago

BjornHartmann commented 4 years ago

Hi, I am trying to use pm-prophet to forecast data with little seasonality. When using the predict function, I would assume that the forecast gets less and less certain over time, some kind of diverging confidence interval. It however seems to me there is only a linear forecast being performed. Does the pm-prophet support what I am looking for?

Here is my code for convenience: sd = .1 N = 200 deltas = np.random.normal(scale=sd, size=N) y = np.cumsum(deltas) x = np.arange(N) df = pd.DataFrame() ## label df["ds"] = pd.date_range(start="2018-01-01", periods=200) df["y"] = y print(df) m = PMProphet(df, auto_changepoints=True, growth=True, name="model") m.fit(method=Sampler.METROPOLIS, chains=1, draws=2000) pm.traceplot(m.trace) plt.show() m.predict(50, alpha=0.2, include_history=True, plot=True) m.plot_components(intercept=False)

plt.show()

image

BjorHart commented 4 years ago

I have seen that this forecast divergence is dependent on whether one uses the auto_changepoint function or not. Why is this the case? As I assume the forecast is based on some kind of randomwalk, it should be irrelevant how many changepoints have been?

luke14free commented 4 years ago

Looks like a bug. Both auto and non auto changepoints predictions' CI should diverge after the observed data. Leaving this open as a reference until I can confirm/fix this

t8ch commented 3 years ago

I have tested the evolution of the CI with the parameters you used but with a longer prediction period. I does indeed diverge.

CI

luke14free commented 3 years ago

I am still not sold that the CIs are properly accounted for/computed in this model @t8ch - I would expect them to open up much more at first sight. It's a complex model so this will take a bit to analyze

t8ch commented 3 years ago

I am still not sold that the CIs are properly accounted for/computed in this model @t8ch - I would expect them to open up much more at first sight. It's a complex model so this will take a bit to analyze

True, we should set up a proper test.