FBProphet在growth='logistic'时出错,Python。

4
这里有一些数据和我在使用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: 

请告诉我如何解决这个问题。

错误/回溯似乎不完整。此外,代码也不完整,无法重现您的问题。 - Ignacio Vergara Kausel
@IgnacioVergaraKausel 不,我只在我的Jupyter笔记本上得到了这么多,让我与您分享屏幕截图:https://ibb.co/dwDdFx - Jaffer Wilson
第一个问题是,由于您没有展示一个MCVE,我无法确定,但您的“data”数据框比所需的“ds”和“Y”列要多。 - Ignacio Vergara Kausel
@IgnacioVergaraKausel,据我所知很奇怪....该列对数据框没有任何影响...我的朋友,你还需要什么其他信息?我已经提供了这些内容....如果您需要其他任何信息,请告诉我.... - Jaffer Wilson
我已经说过它缺少什么了,这不是一个MCVE。 - Ignacio Vergara Kausel
2个回答

9

我认为你应该阅读实现 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)   

我想这肯定会对你有所帮助。


这里有一个打字错误,应该是 'df = data'。 - Habib Karbasian

0

我认为,如果您要创建12个月的未来数据,应该使用(periods=1, freq='Y')而不是'M'。如果您想使用'M',请将periods更改为12。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接