这是我在 python 中使用 Fbprophet 库时遇到的代码数据和错误。
数据
Timestamp Open High Low y Volume \
0 1519084800 11379.2 11388.9 11379.2 11388.9 0.083001
1 1519084860 11362.0 11362.0 11362.0 11362.0 0.017628
2 1519084920 11383.9 11395.0 11370.7 11393.0 3.023621
3 1519084980 11384.3 11399.0 11379.9 11387.3 2.979175
4 1519085040 11395.0 11400.0 11390.1 11390.1 1.430360
ds y_orig y_pred
0 2018-02-20 00:00:00 11388.9 9.340394
1 2018-02-20 00:01:00 11362.0 9.338030
2 2018-02-20 00:02:00 11393.0 9.340754
3 2018-02-20 00:03:00 11387.3 9.340254
4 2018-02-20 00:04:00 11390.1 9.340500
代码:
model = Prophet(growth='logistic')
model.fit(data);
#create 12 months of future data
future_data = model.make_future_dataframe(periods=1, freq = 'M')
#forecast the data for future data
forecast_data = model.predict(future_data)
错误:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-25-c41038b3c799> in <module>()
1 model = Prophet(growth='logistic')
----> 2 model.fit(data);
3
4 #create 12 months of future data
5 future_data = model.make_future_dataframe(periods=1, freq = 'M')
/usr/local/lib/python2.7/dist-packages/fbprophet/forecaster.pyc in fit(self, df, **kwargs)
776 self.history_dates = pd.to_datetime(df['ds']).sort_values()
777
--> 778 history = self.setup_dataframe(history, initialize_scales=True)
779 self.history = history
780 self.set_auto_seasonalities()
/usr/local/lib/python2.7/dist-packages/fbprophet/forecaster.pyc in setup_dataframe(self, df, initialize_scales)
242 df['floor'] = 0
243 if self.growth == 'logistic':
--> 244 assert 'cap' in df
245 df['cap_scaled'] = (df['cap'] - df['floor']) / self.y_scale
246
AssertionError:
请让我知道如何解决此问题。