時間序列與平穩性的介紹

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 模型

平穩性

平穩

  • 趨勢平穩:趨勢為 0

非平穩

Python 中的 ARIMA 模型

平穩性

平穩

  • 趨勢平穩:趨勢為 0
  • 變異數固定

非平穩

Python 中的 ARIMA 模型

平穩性

平穩

  • 趨勢平穩:趨勢為 0
  • 變異數固定
  • 自我相關固定

非平穩

Python 中的 ARIMA 模型

訓練/測試切分

# Train data - all data up to the end of 2018
df_train = df.loc[:'2018']

# Test data - all data from 2019 onwards
df_test = df.loc['2019':]
Python 中的 ARIMA 模型

一起來練習吧!

Python 中的 ARIMA 模型

Preparing Video For Download...