prophet make_future_dataframe()参数说明

 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()准备预测的数据框架,该函数的定义如下:

  1. def make_future_dataframe(self, periods, freq='D', include_history=True):

  2. last_date = self.history['ds'].max()

  3. dates = pd.date_range(

  4. start=last_date,

  5. periods=periods + 1, # closed='right' removes a period

  6. freq=freq,

  7. closed='right') # omits the start date

  8. if include_history:

  9. dates = np.concatenate((np.array(self.history['ds']), dates))

  10. 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

>>> import pandas as pd

>>> import numpy as np

>>> ts = pd.Series(np.random.randint(0,10,10))

>>> ts.index = pd.date_range(start='2020-1-15',periods=10,freq='10D')

>>> ts

2020-01-15    7

2020-01-25    1

2020-02-04    8

2020-02-14    7

2020-02-24    1

2020-03-05    3

2020-03-15    6

2020-03-25    8

2020-04-04    6

2020-04-14    1

Freq: 10D, dtype: int32

====================================================================

>>> 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')
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值