【发布时间】: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