[python]时间序列预测

本文介绍了Python中对周期性时间序列进行预测的方法,包括使用statsmodels库的seasonal_decompose进行周期性特征提取,以及ARIMA模型的理论与实践。文章提到了如何判断和选择ARIMA模型的p, d, q参数,并分享了多个资源链接,如ACF和PACF图像绘制、ARIMA模型选择库pmdarima等。" 111834831,10293159,Spring AOP子类继承父类方法增强处理,"['Spring框架', 'AOP', 'CGLib', '注解', '依赖注入']
摘要由CSDN通过智能技术生成
  1. https://blog.csdn.net/ZVAyIVqt0UFji/article/details/81784639
    周期时间序列的预测
    (有python代码)

具有周期性特征的序列需要将周期性特征提取出来。python里面的statsmodels工具包里面有针对周期性分解的函数seasonal_decompose,我们可以将序列进行分解。seasonal_decompose这个函数里面有个two_sided的参数,默认是True。Trend处理的时候用到移动平均的方法,熟悉此方法的读者就会发现,经过该方法处理以后,序列收尾两段有一部分数据缺失了,但是如果该参数为FALSE,则只有开始的时候有一段缺失值。

  1. 时间序列的一些理论?
    https://wiki.mbalib.com/wiki/时间序列预测法
    https://blog.csdn.net/webzjuyujun/article/details/50618617 http://www.faushine.com/2018/09/30/2018-10-01-time-serise-forecasting/http://www.faushine.com/2018/09/30/2018-10-01-time-serise-forecasting/

  2. Facebook 时间序列预测算法 Prophet 的研究
    https://zhuanlan.zhihu.com/p/52330017

  3. 知乎的一些回答(回头再看)
    https://www.zhihu.com/question/21229371

  4. https://juejin.im/entry/5bba1af56fb9a05ce469df75
    多变量时间序列的预测和建模指南(附Python代码)

  5. https://www.leiphone.com/news/201702/QjrKc9cLWAiqRGhT.html
    时间序列预测教程:如何利用 Python 预测波士顿每月持械抢劫案数量?
    里面有很多分析手法


ARIMA

判断p, d, q
d是差分
如果不用差分就是平稳的,那么d是0
如果是一阶差分才平稳,那d是1.ts_diff_1 = ts.diff(1)
。。。。

p,q的选择有:

  1. arma_order_select_ic
  2. 画画出ACF,PACF的图像
#https://blog.csdn.net/u012735708/article/details/82460962
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
def draw_acf_pacf(ts,lags):
    f = plt.figure(facecolor='white')
    ax1 = f.add_subplot(211)
    plot_acf(ts,ax=ax1,lags=lags)
    ax2 = f.add_subplot(212)
    plot_pacf(ts,ax=ax2,lags=lags)
    plt.subplots_adjust(hspace=0.5)
    plt.show()
draw_acf_pacf(ts_diff_2,30)

https://blog.csdn.net/duxu24/article/details/52079901

seasonal_decompose

https://blog.csdn.net/ZVAyIVqt0UFji/article/details/81784639
https://blog.csdn.net/u012735708/article/details/82460962
https://blog.csdn.net/u011596455/article/details/78650517
https://blog.csdn.net/shine19930820/article/details/72667656
https://www.jianshu.com/p/09e5218f58b4
https://www.biaodianfu.com/time-series-forecasting-codes-python.html (这篇感觉很详细!)

test

trainfile2.csv

date_time,pop
2018-11-12 00:00:00,8933.946387360553
2018-11-12 01:00:00,8988.490918493022
2018-11-12 02:00:00,9094.357585159689
2018-11-12 03:00:00,8988.490918493022
2018-11-12 04:00:00,8988.490918493024
2018-11-12 05:00:00,9074.14913063393
2018-11-12 06:00:00,10789.571764691244
2018-11-12 07:00:00,17151.58225829059
2018-11-12 08:00:00,34289.93003731031
2018-11-12 09:00:00,48453.44305799665
2018-11-12 10:00:00,55580.46013546843
2018-11-12 11:00:00,55285.64358646245
2018-11-12 12:00:00,53865.35841064149
2018-11-12 13:00:00,50751.98869523418
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值