The following code running from anaconda in a Jupyter notebook, trying to see the example in the github repository diagnostics.ipynb
from fbprophet.diagnostics import cross_validation
df_cv = cross_validation(m, '365 days', initial='1825 days', period='365 days')
cutoff = df_cv['cutoff'].unique()[0]
df_cv = df_cv[df_cv['cutoff'] == cutoff]
fig = plt.figure(facecolor='w', figsize=(10, 6))
ax = fig.add_subplot(111)
ax.plot(m.history['ds'].values, m.history['y'], 'k.')
ax.plot(df_cv['ds'].values, df_cv['yhat'], ls='-', c='#0072B2')
ax.fill_between(df_cv['ds'].values, df_cv['yhat_lower'],
df_cv['yhat_upper'], color='#0072B2',
alpha=0.2)
ax.axvline(x=cutoff, c='gray', lw=4, alpha=0.5)
ax.set_ylabel('y')
ax.set_xlabel('ds')
ax.text(x=pd.to_datetime('2010-01-01'),y=12, s='Initial', color='black',
fontsize=16, fontweight='bold', alpha=0.8)
ax.text(x=pd.to_datetime('2012-08-01'),y=12, s='Cutoff', color='black',
fontsize=16, fontweight='bold', alpha=0.8)
ax.axvline(x=cutoff + pd.Timedelta('365 days'), c='gray', lw=4,
alpha=0.5, ls='--')
ax.text(x=pd.to_datetime('2013-01-01'),y=6, s='Horizon', color='black',
fontsize=16, fontweight='bold', alpha=0.8);
Returns this:
AttributeError Traceback (most recent call last)
<ipython-input-5-45aeaa1b3c65> in <module>()
1 from fbprophet.diagnostics import cross_validation
----> 2 df_cv = cross_validation(m, '365 days', initial='1825 days', period='365 days')
3 cutoff = df_cv['cutoff'].unique()[0]
4 df_cv = df_cv[df_cv['cutoff'] == cutoff]
5
/Users/luissanchez/anaconda/lib/python2.7/site-packages/fbprophet/diagnostics.py in cross_validation(model, horizon, period, initial)
143 raise ValueError(
144 'Not enough data for specified horizon, period, and initial.')
--> 145 return simulated_historical_forecasts(model, horizon, k, period)
/Users/luissanchez/anaconda/lib/python2.7/site-packages/fbprophet/diagnostics.py in simulated_historical_forecasts(model, horizon, k, period)
89 for cutoff in cutoffs:
90 # Generate new object with copying fitting options
---> 91 m = model.copy(cutoff)
92 # Train model
93 m.fit(df[df['ds'] <= cutoff])
AttributeError: 'Prophet' object has no attribute 'copy'
Can you check the output of
import fbprophet
fbprophet.__version__
Thank you
import fbprophet
fbprophet.__version__
Returns:
'0.1.1'
I see that the current version is 0.2 (2017.09.02). How do I upgrade from a Conda environment? The version in GitHub does not contains the add_seasonality, add_regressor defs.
Thanks
I assume you installed via conda forge? @rmax do you by chance know what is required to get the new version in conda forge?
It looks like something strange is going on, because the Prophet class does not have any of the new methods for 0.2 (copy, add_seasonality, add_regressor), yet the from fbprophet.diagnostics import cross_validation which is also new to 0.2 isn't raising an exception.
@bletham There is a PR to add the new version. It should be merged soon.
I installed via conda forge, as it is indicated in github. I think the issue will be solved by pushing the new version to conda; and/or updating the GiHub repository so I can get the .py files and manually added them to my prophet directory.
@rmax thanks!!
Most helpful comment
@bletham There is a PR to add the new version. It should be merged soon.