Facebook先知使用少于25个观测值产生时间序列的恒定预测

时间:2019-09-16 16:02:39

标签: python facebook-prophet

facebook-prophet的先知时间序列建模可产生恒定或线性拟合值,并预测少于25个观测值的时间序列。我想知道是什么原因导致这种现象,以及是否有一种方法可以覆盖它。

from fbprophet import Prophet
import pandas
import numpy

training_length = 24
forecast_length = 5
training_endog = numpy.random.randint(50,150,training_length)
training_dates = pandas.date_range('2017-05-31', periods=training_length, freq='M')

df = pandas.DataFrame({'ds':training_dates, 'y':training_endog})

prophet_model = Prophet(

                             holidays=None, 
                             daily_seasonality=False, 
                             weekly_seasonality=False,

                         ).fit(df)

future = prophet_model.make_future_dataframe(periods=5, freq='M', include_history=True)

prophet_model_predictions = prophet_model.predict(future)['yhat'].clip(lower=0).round()

y_long = numpy.concatenate([training_endog, numpy.zeros(5)])

future['y'] = y_long

future['yhat'] = prophet_model_predictions

future.plot(x='ds', y=['y','yhat'])

enter image description here

1 个答案:

答案 0 :(得分:0)

对于上述示例,添加yearly_seasonality=True解决了该问题。