Pythonで学ぶARIMAモデル
James Fulton
Climate informatics researcher
import pmdarima as pm
results = pm.auto_arima(df)
AIC を最小化する逐次探索を実行中
ARIMA(2,0,2)(1,1,1)[12] 切片 : AIC=inf, Time=3.33 sec
ARIMA(0,0,0)(0,1,0)[12] 切片 : AIC=2648.467, Time=0.062 sec
ARIMA(1,0,0)(1,1,0)[12] 切片 : AIC=2279.986, Time=1.171 sec
...
ARIMA(3,0,3)(1,1,1)[12] 切片 : AIC=2173.508, Time=12.487 sec
ARIMA(3,0,3)(0,1,0)[12] 切片 : AIC=2297.305, Time=2.087 sec
最良モデル: ARIMA(3,0,3)(1,1,1)[12]
総フィット時間: 245.812 seconds
print(results.summary())
results.plot_diagnostics()

results = pm.auto_arima( df, # データd=0, # 非季節差分次数start_p=1, # p の初期値 start_q=1, # q の初期値max_p=3, # テストする p の最大値 max_q=3, # テストする q の最大値 )
results = pm.auto_arima( df, # データ ... , # 非季節成分の引数 seasonal=True, # 系列は季節性ありm=7, # 季節周期D=1, # 季節差分次数start_P=1, # P の初期値 start_Q=1, # Q の初期値max_P=2, # テストする P の最大値 max_Q=2, # テストする Q の最大値 )
results = pm.auto_arima( df, # データ ... , # モデル次数のパラメータinformation_criterion='aic', # 最良モデルの指標trace=True, # 学習中に結果を表示error_action='ignore', # 失敗する次数を無視stepwise=True, # 逐次探索を適用 )
# インポート
import joblib
# ファイルパスを指定
filepath ='localpath/great_model.pkl'
# モデルを保存
joblib.dump(model_results_object, filepath)
# ファイルパスを指定
filepath ='localpath/great_model.pkl'
# モデルオブジェクトを読み込み
model_results_object = joblib.load(filepath)
# 新しい観測を追加しパラメータ更新
model_results_object.update(df_new)

Pythonで学ぶARIMAモデル