简体   繁体   English

fbprophet 库中的“yhat”(预测)是如何计算的?

[英]How is 'yhat' (prediction) calculated in the fbprophet library?

I am using fbprophet for time-series predictions in Python and I am wondering how the yhat (prediction) column is calculated.我在 Python 中使用 fbprophet 进行时间序列预测,我想知道yhat (预测)列是如何计算的。 I used the following code.我使用了以下代码。

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)

The future dataframe contains the following columns: 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']

I understand yhat is the prediction, but is it a combination of trend, seasonal, seasonalities, weekly, yearly or something else?我知道yhat是预测,但它是trend, seasonal, seasonalities, weekly, yearly还是其他的组合?

I have tried combining the trend, seasonal, seasonalities, weekly, yearly columns to see if they equal the yhat column, but they do not:我尝试将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

I have been unable to find an answer in the documentation, but apologize if I have simply missed it.我一直无法在文档中找到答案,但如果我只是错过了,请道歉。

I am a beginner of fbprophet but would like to share my guess.我是fbprophet的初学者,但想分享我的猜测。 Even though I'm not sure it is correct, The following equation probably holds true in the default setting of prophet.即使我不确定它是否正确,以下等式可能适用于 prophet 的默认设置。

yhat = trend + seasonal

Hopefully, my answer will help you!希望我的回答能帮到你!

This seems to have changed now.这似乎已经改变了。 Looking at Github code, yhat is calculated as below查看Github代码, yhat计算如下

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

A link to this calculation in the fbprophet source code is foundfbprophet源代码中找到了这个计算的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM