当增长=';物流';python
下面是我在python中使用Fbprophet库时遇到的代码数据和错误 数据当增长=';物流';python,python,python-2.7,facebook-prophet,Python,Python 2.7,Facebook Prophet,下面是我在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
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:
---------------------------------------------------------------------------
AssertionError回溯(上次最近的调用)
在()
1个模型=Prophet(增长=物流)
---->2模型拟合(数据);
3.
4#创建12个月的未来数据
5未来数据=模型。生成未来数据帧(周期=1,频率=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'])。排序_值()
777
-->778历史记录=自我设置\数据帧(历史记录,初始化\比例=真)
779 self.history=历史
780自动设置季节性()
/设置数据框中的usr/local/lib/python2.7/dist-packages/fbprophet/forecaster.pyc(self、df、initialize\u scales)
242 df[‘楼层]]=0
243如果self.growth=='logistic':
-->244在df中断言“cap”
245 df['cap']=(df['cap']-df['floor'])/self.y_比例
246
断言者错误:
请告诉我如何解决此问题。我认为您应该阅读实现
growth='logistic'
的文档。在这里读一读
现在关于你的问题。我想,如果您只是将数据框制作或添加为cap and floor
列,就可以解决这个问题。看看这个:
#considreing your dataframe
df = pandas.read_csv('yourCSV')
cap = df['High']
flr = df['Low']
df['cap'] = cap
df['floor'] = flr
model = Prophet(growth='logistic')
model.fit(data);
#create 12 months of future data
future_data = model.make_future_dataframe(periods=1, freq = 'M')
forecast_data['cap'] = cap
forecast_data['floor'] = flr
#forecast the data for future data
forecast_data = model.predict(future_data)
我想这肯定会对您有所帮助。错误/回溯似乎不完整。代码也不完整,不可能复制您的问题。@IgnacioVergaraKausel不,我只是在我的jupyter笔记本上得到了这么多,让我与您分享屏幕截图:第一个问题,但我不能确定,因为您没有显示MCVE,您的
数据
数据框的列数比所需的ds
和Y
多。@IgnacioVergaraKausel据我所知很奇怪。。。。列对数据帧有任何影响。。。你还需要什么样的信息我的朋友。。我在这里提供了这些东西。。。。如果你还需要什么,请告诉我……我已经说了它缺少什么,这不是MCVE。