facebook / facebook/prophet

Adding a regressor makes unreasonably negative predictions

Open
#2,487 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

I am getting an enormous negative value of prediction when a regressor is used:
![image](https://github.com/facebook/prophet/assets/8807043/b6f27829-079a-4394-9c4a-e2d15e90619f)

Attached is one such dataset of 14 days which corresponds to the first anomaly value and the piece of code which makes Prophet to give out such a strange value:

```
import pandas as pd
import prophet
from prophet import Prophet

print(prophet.__version__)

pdf = pd.read_parquet("__reproduce.parquet")

m = Prophet()
m.add_regressor("regressor1", mode="additive")

pdf_train = pdf.iloc[:-1]
pdf_test = pdf.iloc[-1:]

m.fit(pdf_train)
forecast_test = m.predict(pdf_test[["ds", "regressor1"]])

forecast_test
```
This is the dataset on which the problem reproduces (unpack it beforeap
[__reproduce.zip](https://github.com/facebook/prophet/files/12499650/__reproduce.zip)

Output:
```
1.1.4
[2023-09-01 18:52:04,978] {forecaster.py:931} INFO - Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
[2023-09-01 18:52:04,979] {forecaster.py:931} INFO - Disabling weekly seasonality. Run prophet with weekly_seasonality=True to override this.
[2023-09-01 18:52:04,980] {forecaster.py:931} INFO - Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
[2023-09-01 18:52:05,011] {forecaster.py:401} INFO - n_changepoints greater than number of observations. Using 10.
[2023-09-01 18:52:05,017] {filesystem.py:123} DEBUG - input tempfile: /tmp/tmp_08yqei5/e03znh2e.json
[2023-09-01 18:52:05,021] {filesystem.py:123} DEBUG - input tempfile: /tmp/tmp_08yqei5/_878c5kw.json
[2023-09-01 18:52:05,024] {model.py:1677} DEBUG - idx 0
[2023-09-01 18:52:05,025] {model.py:1678} DEBUG - running CmdStan, num_threads: None
[2023-09-01 18:52:05,026] {model.py:1690} DEBUG - CmdStan args: ['/opt/miniconda3/envs/env_v3/lib/python3.10/site-packages/prophet/stan_model/prophet_model.bin', 'random', 'seed=13792', 'data', 'file=/tmp/tmp_08yqei5/e03znh2e.json', 'init=/tmp/tmp_08yqei5/_878c5kw.json', 'output', 'file=/tmp/tmp_08yqei5/prophet_modelp6_xi7gx/prophet_model-20230901185205.csv', 'method=optimize', 'algorithm=newton', 'iter=10000']

18:52:05 - cmdstanpy - INFO - Chain [1] start processing

[2023-09-01 18:52:05,027] {model.py:1693} INFO - Chain [1] start processing

18:52:05 - cmdstanpy - INFO - Chain [1] done processing

[2023-09-01 18:52:05,067] {model.py:1750} INFO - Chain [1] done processing

```
![image](https://github.com/facebook/prophet/assets/8807043/6a9f8bc4-ea62-4a54-a68a-a4de807e5e4f)

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.