时间序列与平稳性简介

Python 中的 ARIMA 模型

James Fulton

Climate informatics researcher

动机

时间序列无处不在

  • 科学
  • 技术
  • 商业
  • 金融
  • 政策
Python 中的 ARIMA 模型

课程内容

您将学习

  • ARIMA 模型结构
  • 如何拟合 ARIMA 模型
  • 如何优化模型
  • 如何做预测
  • 如何计算预测不确定性
Python 中的 ARIMA 模型

加载与绘图

import pandas as pd
import matplotlib as plt

df = pd.read_csv('time_series.csv', index_col='date', parse_dates=True)
date            values
2019-03-11    5.734193    
2019-03-12    6.288708    
2019-03-13    5.205788    
2019-03-14    3.176578
Python 中的 ARIMA 模型

趋势

fig, ax = plt.subplots()
df.plot(ax=ax)
plt.show()

Python 中的 ARIMA 模型

季节性

Python 中的 ARIMA 模型

周期性

Python 中的 ARIMA 模型

白噪声

白噪声序列的取值不相关

  • 正、正、正、反、正、反,...
  • 0.1,-0.3,0.8,0.4,-0.5,0.9,...
Python 中的 ARIMA 模型

平稳性

平稳

  • 趋势平稳:趋势为零

非平稳

Python 中的 ARIMA 模型

平稳性

平稳

  • 趋势平稳:趋势为零
  • 方差恒定

非平稳

Python 中的 ARIMA 模型

平稳性

平稳

  • 趋势平稳:趋势为零
  • 方差恒定
  • 自相关恒定

非平稳

Python 中的 ARIMA 模型

训练-测试划分

# 训练集:截至 2018 年底的所有数据
df_train = df.loc[:'2018']

# 测试集:2019 年及之后的所有数据
df_test = df.loc['2019':]
Python 中的 ARIMA 模型

Passons à la pratique !

Python 中的 ARIMA 模型

Preparing Video For Download...