【问题标题】:How is 'yhat' (prediction) calculated in the fbprophet library?fbprophet 库中的“yhat”(预测)是如何计算的?
【发布时间】:2018-01-12 01:32:30
【问题描述】:

我在 Python 中使用 fbprophet 进行时间序列预测,我想知道如何计算 yhat(预测)列。我使用了以下代码。

import quandl
import fbprophet

tesla = quandl.get('WIKI/TSLA')
tesla = tesla.reset_index()
tesla = tesla.rename(columns={'Date': 'ds', 'Adj. Close': 'y'})
tesla = tesla[['ds', 'y']]

prophet = fbprophet.Prophet()
prophet.fit(tesla)
future = prophet.make_future_dataframe(periods=365)
future = prophet.predict(future)

future 数据框包含以下列:

['ds', 'trend', 'trend_lower', 'trend_upper', 'yhat_lower', 'yhat_upper', 
'seasonal', 'seasonal_lower', 'seasonal_upper', 'seasonalities', 
'seasonalities_lower', 'seasonalities_upper', 'weekly', 'weekly_lower', 
'weekly_upper', 'yearly', 'yearly_lower', 'yearly_upper', 'yhat']

我知道yhat 是预测,但它是trend, seasonal, seasonalities, weekly, yearly 的组合还是其他?

我已尝试合并 trend, seasonal, seasonalities, weekly, yearly 列以查看它们是否等于 yhat 列,但它们不等于:

future['combination'] = future['trend'] + future['seasonal'] + future['weekly'] + future['yearly'] + future['seasonalities']

print(future[['combination', 'yhat']].head())

   combination       yhat
0    57.071956  27.681139
1    55.840545  27.337270
2    53.741200  26.704090
3    51.874192  26.148355
4    47.827763  25.065950

我无法在文档中找到答案,但如果我只是错过了它,我深表歉意。

【问题讨论】:

    标签: python time-series prediction


    【解决方案1】:

    我是fbprophet 的初学者,但想分享一下我的猜测。 尽管我不确定它是否正确,但以下等式可能在先知的默认设置中成立。

    yhat = trend + seasonal
    

    希望我的回答对你有所帮助!

    【讨论】:

    • 谢谢。这是在文档中吗?
    • @caseWestern 从他们的Homepage 你可以阅读article
    • @user32185。我想你是对的。我查看了github源代码,在Prophet对象的predict方法下找到了df2['yhat'] = df2['trend'] + df2['seasonal']
    【解决方案2】:

    这似乎已经改变了。查看 Github 代码,yhat 计算如下

    yhat = (trend * (1 + multiplicative_terms) + additive_terms
    

    fbprophet 源代码中找到了此计算的链接

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 2019-04-19
      • 1970-01-01
      • 2017-10-04
      • 2020-10-31
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 2014-06-01
      相关资源
      最近更新 更多