Performing stepwise search to minimize aic ARIMA(2,0,2)(0,0,0)[0] : AIC=413.503,…
- User
Performing stepwise search to minimize aic ARIMA(2,0,2)(0,0,0)[0] : AIC=413.503, Time=2.21 sec ARIMA(0,0,0)(0,0,0)[0] : AIC=436.547, Time=0.03 sec ARIMA(1,0,0)(0,0,0)[0] : AIC=412.275, Time=0.03 sec ARIMA(0,0,1)(0,0,0)[0] : AIC=408.733, Time=0.48 sec ARIMA(1,0,1)(0,0,0)[0] : AIC=inf, Time=2.27 sec ARIMA(0,0,2)(0,0,0)[0] : AIC=400.906, Time=0.89 sec ARIMA(1,0,2)(0,0,0)[0] : AIC=inf, Time=3.63 sec ARIMA(0,0,3)(0,0,0)[0] : AIC=395.301, Time=1.27 sec ARIMA(1,0,3)(0,0,0)[0] : AIC=inf, Time=3.47 sec ARIMA(0,0,4)(0,0,0)[0] : AIC=inf, Time=3.51 sec ARIMA(1,0,4)(0,0,0)[0] : AIC=inf, Time=4.50 sec ARIMA(0,0,3)(0,0,0)[0] intercept : AIC=397.282, Time=2.09 sec
Best model: ARIMA(0,0,3)(0,0,0)[0]
Total fit time: 24.674 seconds預測值: Forecast 2019-12-31 NaN 2020-01-31 -0.134268 2020-02-29 0.138182 2020-03-31 -0.187955 2020-04-30 0.000000 2020-05-31 0.000000 2020-06-30 0.000000 2020-07-31 0.000000 2020-08-31 0.000000 2020-09-30 0.000000
置信區間: Lower CI Upper CI 2019-12-31 -2.524456 2.255919 2020-01-31 -2.874890 3.151254 2020-02-29 -3.210415 2.834506 2020-03-31 -3.101968 3.101968 2020-04-30 -3.101968 3.101968 2020-05-31 -3.101968 3.101968 2020-06-30 -3.101968 3.101968 2020-07-31 -3.101968 3.101968 2020-08-31 -3.101968 3.101968 2020-09-30 -3.101968 3.101968
##最終輸出值
- Assistant
Based on the stepwise search for the ARIMA model, the best model identified is ARIMA(0,0,3)(0,0,0)[0] with an AIC of 395.301. This model showed the lowest AIC value during the search process, indicating it's the best fit among the tested models.
Forecast Values:
Date Forecast 2019-12-31 NaN 2020-01-31 -0.134268 2020-02-29 0.138182 2020-03-31 -0.187955 2020-04-30 0.000000 2020-05-31 0.000000 - User
import pandas as pd import numpy as np import matplotlib.pyplot as plt from pmdarima import auto_arima
假設 ts_data_diff 是你的差分後的時間序列數據
ts_data_diff = time_series_data.diff().dropna()
使用 auto_arima 自動搜尋最佳參數
model = auto_arima(ts_data_diff, seasonal=False, # 如果有季節性,設置為 True,並將季節性周期設置為季節性週期 stepwise=True, # 是否使用逐步搜索 trace=True, # 是否顯示搜尋過程 error_action='ignore', # 忽略不合適的模型 suppress_warnings=True) # 壓制警告
預測未來n個時間點
n_periods = 10 # 設定未來要預測的時間點數量 forecast, conf_int = model.predict(n_periods=n_periods, return_conf_int=True)
獲取預測的時間索引
forecast_index = pd.date_range(start=ts_data_diff.index[-1] + pd.offsets.MonthEnd(0), periods=n_periods, freq='M')
將預測結果和置信區間轉換為DataFrame以便可視化
forecast_df = pd.DataFrame(forecast, index=forecast_index, columns=['Forecast']) conf_int_df = pd.DataFrame(conf_int, index=forecast_index, columns=['Lower CI', 'Upper CI'])
- Assistant
To modify your code to manually specify the parameters of the ARIMA model instead of using
auto_arima, you can use theARIMAclass from the library. Below is the modified Python code that achieves this: