Sawtooth pattern forecast
- Dominant language
- Python
- Stars
- 20.4k
- Forks
- 4.6k
- Avg merge
- 19h 52m
- Merged PRs (30d)
- 1
Description
I am using Facebook Prophet to forecast data that follow a set of particular patterns and one of them is a sawtooth pattern. I'm getting some peculiar results when using Prophet with default parameters. It doesn't seem to track the original data at all and generates a sinusoidal time series around the overall mean of the training data. You can find a simple reproducible Python script in the following section. I was wondering if someone would be able to shed some light as to why Prophet behaves that way and what I can do to help it track the training data better and produce better forecasts.
## To Reproduce
```python
import matplotlib.pyplot as plt
from scipy import signal
from fbprophet import Prophet
import pandas as pd
import numpy as np
def main(num_points: int, interval_seconds: int):
t = np.linspace(0, num_points * interval_seconds, num_points, False, dtype=int)
x = pd.to_datetime(t, unit='s')
y = signal.sawtooth(0.000005 * np.pi * t, 0.6)
plt.plot(x, y)
plt.show()
df = pd.DataFrame({'ds': pd.to_datetime(x, unit='s'), 'y': y})
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=7 * 24, freq='H')
forecast = m.predict(future)
m.plot(forecast).show()
m.plot_components(forecast).show()
if __name__ == '__main__':
main(2880, 15 * 60)
```
## Training Data

## Forecast Result

## Components

Contributor guide
Assessment
This issue has not been assessed yet.