从 auto-arima 摘要中获取 p、q、d 和 P、D、Q、m 值

Get p,q,d and P, D, Q, m values from auto-arima summary

我已经使用金字塔 ARIMA 中的 auto-arima 构建了多个 SARIMA 模型,我想从模型中提取 p、q、d 和 P、D、Q、m 值并将它们分配给变量,以便我可以在未来的模型中使用它们。

我可以使用 model.summary() 来查看这些值,但这对我来说不是很好,因为我需要将它们分配给一个变量。

您可以使用以下技巧来解决您的问题,

#In this case I have used model of ARIMA,
#You can convert model.summary in string format and find its parameters
#using regular expression.

import re
summary_string = str(model.summary())
param = re.findall('ARIMA\(([0-9]+), ([0-9]+), ([0-9]+)',summary_string)
p,d,q = int(param[0][0]) , int(param[0][1]) , int(param[0][2])
print(p,d,q)

最终输出: Click here for my model.summary() output.

通过这种方式,您可以在循环的帮助下存储所有模型的参数值。

要从 AutoARIMA 模型摘要中获取顺序和 seasonal_order 值,我们可以使用 get_params()。
https://scikit-learn.org/stable/modules/generated/sklearn.base.BaseEstimator.html

单击下面的链接以获得更好的图片。

This is the model summary of AUTOARIMA\

model = auto_arima(df_weekly1['Value'], start_p = 1, start_q = 1, 
                      max_p = 3, max_q = 3, m = 12, 
                      start_P = 0, seasonal = True, 
                      d = None, D = 1, trace = True)
model.summary() 

We can get the model summary values using get_params(), the output of the get_params function will be a dict datatype.

get_parametes = model.get_params()
print(type(get_parametes))
get_parametes

Get the required values using Key-Value pair and assign the same to a variable.

order_aa = get_parametes.get('order')
seasonal_order_aa = get_parametes.get('seasonal_order')
print('order:', order_aa)
print('seasonal_order:', seasonal_order_aa)
print('order DTYPE:', type(order_aa))
print('seasonal_order DTYPE:', type(seasonal_order_aa))

model_ss = SARIMAX(train['Col_Name'], 
            order = (order_aa[0], order_aa[1], order_aa[2]),  
            seasonal_order =(seasonal_order_aa[0], 
seasonal_order_aa[1], seasonal_order_aa[2], seasonal_order_aa[3])) 

result_ss = model_ss.fit() 
result_ss.summary()