facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.26k stars 4.51k forks source link

Trouble Predicting Daily Spikes #1297

Closed user-github2018 closed 4 years ago

user-github2018 commented 4 years ago

Hello,

I am new to prophet and trying to predict data that contains daily spikes without much success. The graph below does not correctly identify the spikes.

I think I must be missing something pretty basic. Here is my code:

import pandas as pd from fbprophet import Prophet

df = pd.read_csv('output1.csv') colnames=['ds','y'] df=df[colnames]

m = Prophet(changepoint_prior_scale=0.01).fit(df) future = m.make_future_dataframe(periods=300, freq='H') fcst = m.predict(future) fig = m.plot(fcst)

image

benmwhite commented 4 years ago

Are these spikes appearing with some sort of regular or known pattern? In that case you can do something like decreasing (edit: whoops meant increasing) the appropriate seasonal prior scale to fit closer to the training data, or incorporating known events in the holiday data frame.

Unfortunately there isn't a magic bullet if the spikes appear to be happening at random. If you want to estimate the magnitude or frequency of the spikes then you can look into extreme value analysis techniques, or if you need to stick with a time series approach then maybe consider binning the observations in wider time bands (like minutes -> hours, hours -> days, or days -> weeks) to reduce the relative overall variance of the observed values.

bletham commented 4 years ago

+1 for @benmwhite's comments. Prophet does well on time series with regular structure, like weekly and yearly seasonality. The pattern here doesn't look very seasonal, and so the model isn't going to be able to learn it.