基本信息
源码名称:ARIMA模型预测(ARIMA.py)
源码大小:6.21KB
文件格式:.py
开发语言:Python
更新时间:2020-10-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 4 元 
   源码介绍
ARIMA模型预测

#划分训练集和测试集
train_ts=ts[:round(data['total'].shape[0]*0.8)]
test_ts=ts[round(data['total'].shape[0]*0.8):]
#差分数据
ts.diff()
#时序图检查查看
train_ts.plot(figsize=(12,8))
##d=0 和d=1差不多,所以就选d=0
#ADF检验
ADF(train_ts)
print(u'原始序列的ADF检验结果为:',ADF(train_ts)[1]) 
#LB检验
acorr_ljungbox(train_ts,lags=1)  #值很小,说明不是白噪声
print(u'原始序列的白噪声检验结果为',acorr_ljungbox(train_ts,lags=1))
#
#模型拟合
fig=plt.figure(figsize=(12,8))
ax1=fig.add_subplot(211)
fig=sm.graphics.tsa.plot_acf(train_ts,lags=40,ax=ax1)
fig=plt.figure(figsize=(12,8))
ax2=fig.add_subplot(212)
fig=sm.graphics.tsa.plot_pacf(train_ts,lags=40,ax=ax2)