facebook / facebook/prophet

Regressor recognized in forecast but not on the fitted data

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

Description

Hi ,

Regressor is not recognized in the prophet model. The future date has the regressor value but regressor dates for the fitted date does not have a regressor value. The same happens when I import through excel with a regressor.
Help on this would be great.
Below is the code .
dfs= reading . csv file raw data
![Capture](https://user-images.githubusercontent.com/33106986/128216602-5e87d373-2cf2-4956-8f5b-c5161b24a4c4.PNG)

peak1=['2019-10-05', '2020-10-05']
from prophet import Prophet
df_prophet=dfs[['ds', 'y']]
df_prophet["first_regressor"]=''
df_prophet["ds"] = df_prophet["ds"].astype(str)
for regressor in range(len(df_prophet)):
for peak in range(len(peak1)):

if peak1[peak] ==df_prophet.iloc[regressor,0]:

df_prophet["first_regressor"].iloc[regressor]=1
break
else:
df_prophet["first_regressor"].iloc[regressor]=0

m = Prophet()
m.add_regressor('first_regressor')
m.add_country_holidays(country_name='US')
m.add_seasonality(
name='weekly', period=7, fourier_order=3, prior_scale=0.1)
m.fit(df_prophet)
future = m.make_future_dataframe(periods=120)

### Create future dataframe for prediction with regressor

future["first_regressor"]=''
future_peak1_dt=['2021-10-20']

future["ds"] = future["ds"].astype(str)

for futurepeak1dt in range(len(future)):
for future_first_peak in range(len(future_peak1_dt)):

if str(future_peak1_dt[future_first_peak])==str(future.iloc[futurepeak1dt,0]):
future["first_regressor"].iloc[futurepeak1dt]=1
break
else:
future["first_regressor"].iloc[futurepeak1dt]=0

forecast=m.predict(future)

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.