facebook / facebook/prophet

Strange forecasting when input sequence has time gaps

Open
#2,412 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
20.4k
Forks
4.6k
Avg merge
19h 52m
Merged PRs (30d)
1

Description

**Context**
I am using the following model (fbprophet version 0.7.1)
```
model = Prophet(daily_seasonality = True, yearly_seasonality = False, weekly_seasonality = True,
seasonality_mode = 'additive', interval_width = 0.99, changepoint_range = 0.8)
model = model.fit(preceding_data) # 30 days of preceding data spaced by 1 hour
pred = model.predict(future_timestamps) # forecast for several hours in the future
```
Sometimes preceding data would have time gaps due to insufficient sample size for at some time steps. Most of the time, this does not pose a problem since the `ds` column in preceding data is not required to be equally spaced.

**Problem**
*Sometimes* for some reason the forecast is way off. Below, 289 of the 720 points of preceding data is missing, mostly when the value of `y` was close to 0. Nothing indicates in the preceding data that the value of `y` might surpass 1 in the future, but Prophet make a very strange forecast:

![Screenshot 2023-04-20 at 11 19 34](https://user-images.githubusercontent.com/58189334/233321203-0b66a881-bcd1-47d9-8daf-c522b45ecdb5.png)

This is due to the "daily" component of the prediction:
![Screenshot 2023-04-20 at 11 20 14](https://user-images.githubusercontent.com/58189334/233321227-ae4a37b0-3930-4eb1-8e15-8fafab534a2a.png)

Interestingly, if I fill in the time gaps with missing data, the problem disappears:
![Screenshot 2023-04-20 at 11 20 59](https://user-images.githubusercontent.com/58189334/233321244-0f7474a0-9394-4857-8c26-616236b09a69.png)

This makes me think that the time gaps are somehow responsible for the strange forecast. It is unclear to me why this happens in this case, but works normally in the majority of cases.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.