Regressor recognized in forecast but not on the fitted data
- 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

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
Assessment
This issue has not been assessed yet.