Facebook时间序列预测工具fbprophet – 标点符
def make_future_dataframe(self, periods, freq='D', include_history=True):
"""Simulate the trend using the extrapolated generative model.
Parameters
----------
periods: Int number of periods to forecast forward.
freq: Any valid frequency for pd.date_range, such as 'D' or 'M'.
include_history: Boolean to include the historical dates in the data
frame for predictions.
Returns
-------
pd.Dataframe that extends forward from the end of self.history for the
requested number of periods.
"""
make_future_dataframe()参数说明:
- periods: 向前预测步数
- freq: 预测单位小时为’H’,天为’D’,月为’M’
- include_history: 是否包含历史数据的预测
=====================================================================
facebook开源的prophet时间序列预测工具---识别多种周期性、趋势性(线性,logistic)、节假日效应,以及部分异常值 - bonelee - 博客园
make_future_dataframe()准备预测的数据框架,该函数的定义如下:
-
def make_future_dataframe(self, periods, freq='D', include_history=True):
-
last_date = self.history['ds'].max()
-
dates = pd.date_range(
-
start=last_date,
-
periods=periods + 1, # closed='right' removes a period
-
freq=freq,
-
closed='right') # omits the start date
-
if include_history:
-
dates = np.concatenate((np.array(self.history['ds']), dates))
-
return pd.DataFrame({'ds': dates})
periods:指定要预测的时长,要根据freq这个参数去设置。假如freq='D',那么粒度为天,periods则指定要预测未来多少天的数据。如果freq='H‘,则periods指定要预测未来多少小时的数据(当然,要在框架支持粒度为小时的前提下才能运用)。
include_history:是否包含历史数据,保持默认就好。
=========================================================================
6-Pandas时序数据处理(日期范围pd.date_range()、频率(基础频率表)及移动(shift()、rollforward()、rollback())) - 大脸猫12581 - 博客园
若有以下时间序列,如何在每月月末显示该月数据的均值?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
====================================================================
>>> pd.date_range(start='2022-08-14 08:01:00',periods=24,freq='5T')
DatetimeIndex(['2022-08-14 08:01:00', '2022-08-14 08:06:00',
'2022-08-14 08:11:00', '2022-08-14 08:16:00',
'2022-08-14 08:21:00', '2022-08-14 08:26:00',
'2022-08-14 08:31:00', '2022-08-14 08:36:00',
'2022-08-14 08:41:00', '2022-08-14 08:46:00',
'2022-08-14 08:51:00', '2022-08-14 08:56:00',
'2022-08-14 09:01:00', '2022-08-14 09:06:00',
'2022-08-14 09:11:00', '2022-08-14 09:16:00',
'2022-08-14 09:21:00', '2022-08-14 09:26:00',
'2022-08-14 09:31:00', '2022-08-14 09:36:00',
'2022-08-14 09:41:00', '2022-08-14 09:46:00',
'2022-08-14 09:51:00', '2022-08-14 09:56:00'],
dtype='datetime64[ns]', freq='5T')