季节性时间序列

Python 中的 ARIMA 模型

James Fulton

Climate informatics researcher

季节性数据

  • 具有可预测、重复的模式
  • 在固定时间后重复
Python 中的 ARIMA 模型

季节性分解

Python 中的 ARIMA 模型

季节性分解

time series = trend + seasonal + residual

Python 中的 ARIMA 模型

使用 statsmodels 的季节性分解

# Import 
from statsmodels.tsa.seasonal import seasonal_decompose
# Decompose data
decomp_results = seasonal_decompose(df['IPG3113N'], period=12)
type(decomp_results)
statsmodels.tsa.seasonal.DecomposeResult
Python 中的 ARIMA 模型

使用 statsmodels 的季节性分解

# Plot decomposed data
decomp_results.plot()
plt.show()

Python 中的 ARIMA 模型

用 ACF 寻找季节周期

Python 中的 ARIMA 模型

用 ACF 识别季节性数据

Python 中的 ARIMA 模型

去趋势化时间序列

# Subtract long rolling average over N steps
df = df - df.rolling(N).mean()

# Drop NaN values df = df.dropna()

Python 中的 ARIMA 模型

用 ACF 识别季节性数据

# Create figure
fig, ax = plt.subplots(1,1, figsize=(8,4))

# Plot ACF
plot_acf(df.dropna(), ax=ax, lags=25, zero=False)
plt.show()

Python 中的 ARIMA 模型

ARIMA 与季节性数据

Python 中的 ARIMA 模型

Vamos praticar!

Python 中的 ARIMA 模型

Preparing Video For Download...