【问题标题】:Get p,q,d and P, D, Q, m values from auto-arima summary从 auto-arima 汇总中获取 p,q,d 和 P,D,Q,m 值
【发布时间】:2019-11-28 05:02:09
【问题描述】:

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

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

【问题讨论】:

  • 你能展示一些产生这个输出的实际代码,而不是输出的图像吗?当您引用model.summary() 时,不清楚您的model 是什么类型。

标签: python arima pyramid-arima


【解决方案1】:

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

#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.

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

【讨论】:

    【解决方案2】:

    要从 AutoARIMA 模型摘要中获取 order 和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() 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-13
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-06
      • 2019-05-09
      • 2014-06-10
      相关资源
      最近更新 更多