Prophet是一个基于加法模型的时间序列数据预测程序,其中非线性趋势用于预测年度、每周和每日的季节性以及假日效应。它非常适用于具有强烈季节性影响或历史数据有周期的时间序列。Prophet对数据缺失和趋势变化非常敏感,通常能够很好地处理异常值。 pip install fbprophet prophet模型的结构如下: y(t)=g(t)+s(t)+h(t)+ϵ 其中,g(t)是趋势(trend)函数,用来分析时间序列中非周期性的变化。 s(t)代表周期性的变化,例如一周或一年的周期性。 h(t)代表节假日等偶然一天或几天造成的影响。 ϵ是误差项,代表本模型没有考虑到的误差的影响。

1. 其中,C是饱和值(承载能力),k是增长率,m是偏置参数。

import pandas as pd
from prophet import Prophet
# Python
df = pd.read_csv('test.csv')
print(df.head())
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=365)
print(future.tail())
forecast = m.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail())
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
from prophet.plot import plot_plotly, plot_components_plotly
plot_plotly(m, forecast)
plot_components_plotly(m, forecast)