Using python
Pip version: 0.4.post2
I've trained and saved a prophet model to a .pkl file. When loading the file and then predicting, I get KeyError: 'condition_name':
File "main.py", line 5
prediction = prophet_model.predict(future)
File "...../lib/python3.7/site-packages/fbprophet/forecaster.py", line 1172, in predict
df = self.setup_dataframe(df.copy())
File "...../lib/python3.7/site-packages/fbprophet/forecaster.py", line 257, in setup_dataframe
condition_name = props['condition_name']
Using prophet_model.seasonalities.values() as done in setup_dataframe, there doesn't seem to be a condition_name key?
# prophet_model.seasonalities
{'weekly': {'fourier_order': 3, 'mode': 'additive', 'period': 7, 'prior_scale': 10.0}, 'yearly': {'fourier_order': 50, 'mode': 'additive', 'period': 365.25, 'prior_scale': 10.0}}
# prophet_model.seasonalities.values()
dict_values([{'period': 365.25, 'fourier_order': 50, 'prior_scale': 10.0, 'mode': 'additive'}, {'period': 7, 'fourier_order': 3, 'prior_scale': 10.0, 'mode': 'additive'}])
I can't figure out how to replicate this, any ideas?
The condition_name key to seasonality was added in v0.5, and in that version it's required to be present in seasonalities meaning a pickled version from v0.4 can't be used directly in v.05 .
If you are using v0.4 I however don't know why that would occur.
A possible temporary fix could be to something like:
for seasonality in prophet_model.seasonalities:
prophet_model.seasonalities[seasonality]['condition_name'] = None
before predicting, but I haven't tried myself
The condition_name key to seasonality was added in v0.5, and in that version it's required to be present in seasonalities meaning a pickled version from v0.4 probably can't be possible to use in v.05 .
If you are using v0.4 I however don't know why that would occur.
A possible temporary fix could be to something like:for seasonality in prophet_model.seasonalities: prophet_model.seasonalities[seasonality]['condition_name'] = Nonebefore predicting, but I haven't tried myself
Brilliant, the version bump looks to be the reason so I'm confident it won't happen again.
This is largely undetected because I can't seem to find any changelog for the 0.5 version... why isn't there one on GH?
Edit: Changelog request has also been made here https://github.com/facebook/prophet/issues/968
Also, why only a minor version if this isn't a backwards-compatible change? 馃
Is the problem with backwards-compatible only around pickled objects, or something else as well? I don't think you should generally expect pickled objects to work with new versions. See for example Scikit-learns pickle instructions:
While models saved using one version of scikit-learn might load in other versions, this is entirely unsupported and inadvisable. It should also be kept in mind that operations performed on such data could give different and unexpected results. (https://scikit-learn.org/stable/modules/model_persistence.html)
For why there's no change-log you would have to ask the maintainers, but that discussion can probably be kept in that other issue
Agreed, thanks for your help!
Most helpful comment
The condition_name key to seasonality was added in v0.5, and in that version it's required to be present in seasonalities meaning a pickled version from v0.4 can't be used directly in v.05 .
If you are using v0.4 I however don't know why that would occur.
A possible temporary fix could be to something like:
before predicting, but I haven't tried myself