Prophet: plot_components fail if `floor` column exists

Created on 9 Oct 2017  路  2Comments  路  Source: facebook/prophet

If you follow the documentation https://facebook.github.io/prophet/docs/saturating_forecasts.html and test the method plot_components it will show the error because the predict drop the cap and floor column:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-23-cfc41cac3540> in <module>()
----> 1 m.plot_components(forecast)

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/fbprophet/forecaster.py in plot_components(self, fcst, uncertainty, plot_cap, weekly_start, yearly_start)
   1311             elif plot == 'weekly':
   1312                 self.plot_weekly(
-> 1313                     ax=ax, uncertainty=uncertainty, weekly_start=weekly_start)
   1314             elif plot == 'yearly':
   1315                 self.plot_yearly(

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/fbprophet/forecaster.py in plot_weekly(self, ax, uncertainty, weekly_start)
   1401         days = (pd.date_range(start='2017-01-01', periods=7) +
   1402                 pd.Timedelta(days=weekly_start))
-> 1403         df_w = self.seasonality_plot_df(days)
   1404         seas = self.predict_seasonal_components(df_w)
   1405         days = days.weekday_name

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/fbprophet/forecaster.py in seasonality_plot_df(self, ds)
   1375             df_dict[name] = 0.
   1376         df = pd.DataFrame(df_dict)
-> 1377         df = self.setup_dataframe(df)
   1378         return df
   1379 

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/fbprophet/forecaster.py in setup_dataframe(self, df, initialize_scales)
    237         if self.logistic_floor:
    238             if 'floor' not in df:
--> 239                 raise ValueError("Expected column 'floor'.")
    240         else:
    241             df['floor'] = 0

ValueError: Expected column 'floor'.
bug ready

All 2 comments

Thanks, this is a bug. https://github.com/facebook/prophet/commit/a43cfe8995e86f6217da93096f39f4d045b487e1 fixes it, so if you download the current github version and install from source it will work.

Fix pushed to PyPI in v0.2.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

datafool picture datafool  路  3Comments

maxwell873 picture maxwell873  路  3Comments

ChaymaeHarfoush picture ChaymaeHarfoush  路  3Comments

andrew-pollock picture andrew-pollock  路  3Comments

germayneng picture germayneng  路  3Comments