我在火车数据集上应用SARIMA,在其中我通过网格搜索来搜索SARIMA的顺序,在该网格中我获得了最低的AIC分数。我想将所有结果保存在具有ARIMA顺序,季节性顺序和AIC得分的列表中,然后我要选择具有最低AIC得分的参数。
p = d = q = range(0, 2)
pdq = list(itertools.product(p, d, q))
seasonal_pdq = [(x[0], x[1], x[2], 12) for x in list(itertools.product(p, d, q))]
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(train,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=False,
enforce_invertibility=False)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(param, param_seasonal, results.aic))
except:
continue
我想将结果存储在a
中,例如a[1] = [(0,1,1),(1,1,1,12),234,56]
然后在a
中找到最低的AIC得分并将其应用于以下模型拟合
mod = sm.tsa.statespace.SARIMAX(train,
order=(0, 1, 1),
seasonal_order=(1, 1, 1, 12),
enforce_stationarity=False,
enforce_invertibility=False)
results = mod.fit()