Search code examples
pythonarimapyramid-arima

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


I have built multiple SARIMA models using auto-arima from pyramid ARIMA and would like to extract the p,q,d and P, D, Q, m values from the model and assign them to variables so that I can use them in a future model.

I can use model.summary() to see the values, but this isn't much good to me because I need to assign them to a variable.

enter image description here


Solution

  • You can use following technique to solve your problem,

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

    Final output : enter image description here Click here for my model.summary() output.

    In this way you can store parameter values of all your models with help of loop.