0

When I run auto_arima() from pmdarima, the console prints these statements to the console for example:

Performing stepwise search to minimize aic
 ARIMA(2,0,2)(1,0,1)[7] intercept   : AIC=-296.496, Time=0.88 sec
 ARIMA(0,0,0)(0,0,0)[7] intercept   : AIC=-302.486, Time=0.30 sec
 ARIMA(1,0,0)(1,0,0)[7] intercept   : AIC=-299.880, Time=0.70 sec
 ARIMA(0,0,1)(0,0,1)[7] intercept   : AIC=-299.529, Time=0.70 sec
 ARIMA(0,0,0)(0,0,0)[7]             : AIC=598.722, Time=0.27 sec
 ARIMA(0,0,0)(1,0,0)[7] intercept   : AIC=-301.889, Time=0.61 sec
 ARIMA(0,0,0)(0,0,1)[7] intercept   : AIC=-301.608, Time=0.59 sec
 ARIMA(0,0,0)(1,0,1)[7] intercept   : AIC=-299.014, Time=0.64 sec
 ARIMA(1,0,0)(0,0,0)[7] intercept   : AIC=-300.553, Time=0.35 sec
 ARIMA(0,0,1)(0,0,0)[7] intercept   : AIC=-300.558, Time=0.41 sec
 ARIMA(1,0,1)(0,0,0)[7] intercept   : AIC=-299.403, Time=0.44 sec

Best model:  ARIMA(0,0,0)(0,0,0)[7] intercept
Total fit time: 5.934 seconds
Out[3]: 
ARIMA(order=(0, 0, 0), scoring_args={}, seasonal_order=(0, 0, 0, 7),
      suppress_warnings=True)

How can I save these print statements to a .txt file? I will train about 300 of these models and want to be able to log the different AIC values for each configuration. Is there a way to capture these outputs while auto_arima() finds the best model?

LGR
  • 402
  • 3
  • 18
  • It doesn't looks the best way but: https://stackoverflow.com/questions/27994137/how-to-save-the-output-of-a-cell-in-ipython-notebook – Kang San Lee Apr 22 '22 at 09:19
  • 1
    In what context are you executing this code ? If it's a python script, you can write its output with `python3 my_script.py > output.txt` – Big Bro Apr 22 '22 at 09:48
  • Thanks Big Bro! This is exactly what I needed. I run it as a simple python script, so your solution works like a charm. – LGR Apr 22 '22 at 10:16

0 Answers0