時系列分析でSARIMAXを使用しようとして
パラメータ最適算出しようとするとエラーがでて困っています。
このエラーの意味 か 対処法について、どなたかアドバイスをお願いします。
データはアイスクリームの月次売上の様な、12か月の周期性をもった、月間販売数です。
import optuna s = 12 def objective(trial): # 各次数の探索範囲を設定します p = trial.suggest_int('p', 0, 3) d = trial.suggest_int('d', 0, 2) q = trial.suggest_int('q', 0, 3) P = trial.suggest_int('P', 0, 3) D = trial.suggest_int('D', 0, 2) Q = trial.suggest_int('Q', 0, 3) # ↑から選ばれた次数を用いてモデルを構築します model = sm.tsa.statespace.SARIMAX(raw_data_202003, order=(p, d, q), seasonal_order=(P, D, Q, s), enforce_stationarity=False, enforce_invertibility=False) fitting_result = model.fit() # BICの値を取得します bic = fitting_result.bic return bic # 目的関数objectiveの値を最小化するようなパラメータを探索します study = optuna.create_study(direction='minimize') # 試行回数を20回に指定します study.optimize(objective,20) trial_dataframe = study.trials_dataframe() # BICが最小となるパラメータの組み合わせ idx = trial_dataframe.value.idxmin()
でてくるエラーは、
TypeError Traceback (most recent call last) <ipython-input-65-a81496b1dd4a> in <module>() 22 study = optuna.create_study(direction='minimize') 23 # 試行回数を20回に指定します ---> 24 study.optimize(objective,5) 25 trial_dataframe = study.trials_dataframe() 26 # BICが最小となるパラメータの組み合わせ ~\Anaconda3\lib\site-packages\optuna\study.py in optimize(self, func, n_trials, timeout, n_jobs, catch, callbacks, gc_after_trial) 259 if n_jobs == 1: 260 self._optimize_sequential(func, n_trials, timeout, catch, callbacks, --> 261 gc_after_trial) 262 else: 263 self._optimize_parallel(func, n_trials, timeout, n_jobs, catch, callbacks, ~\Anaconda3\lib\site-packages\optuna\study.py in _optimize_sequential(self, func, n_trials, timeout, catch, callbacks, gc_after_trial) 441 break 442 --> 443 self._run_trial_and_callbacks(func, catch, callbacks, gc_after_trial) 444 445 def _optimize_parallel( ~\Anaconda3\lib\site-packages\optuna\study.py in _run_trial_and_callbacks(self, func, catch, callbacks, gc_after_trial) 518 # type: (...) -> None 519 --> 520 trial = self._run_trial(func, catch, gc_after_trial) 521 if callbacks is not None: 522 frozen_trial = self._storage.get_trial(trial._trial_id) ~\Anaconda3\lib\site-packages\optuna\study.py in _run_trial(self, func, catch, gc_after_trial) 537 538 try: --> 539 result = func(trial) 540 except exceptions.TrialPruned as e: 541 message = 'Setting status of trial#{} as {}. {}'.format(trial_number, <ipython-input-65-a81496b1dd4a> in objective(trial) 13 # ↑から選ばれた次数を用いてモデルを構築します 14 model = sm.tsa.statespace.SARIMAX(raw_data_202003, order=(p, d, q), seasonal_order=(P, D, Q, s), ---> 15 enforce_stationarity=False, enforce_invertibility=False) 16 fitting_result = model.fit() 17 # BICの値を取得します ~\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\sarimax.py in __init__(self, endog, exog, order, seasonal_order, trend, measurement_error, time_varying_regression, mle_regression, simple_differencing, enforce_stationarity, enforce_invertibility, hamilton_representation, **kwargs) 497 # Initialize the statespace 498 super(SARIMAX, self).__init__( --> 499 endog, exog=exog, k_states=k_states, k_posdef=k_posdef, **kwargs 500 ) 501 ~\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py in __init__(self, endog, k_states, exog, dates, freq, **kwargs) 111 super(MLEModel, self).__init__(endog=endog, exog=exog, 112 dates=dates, freq=freq, --> 113 missing='none') 114 115 # Store kwargs to recreate model ~\Anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py in __init__(self, endog, exog, dates, freq, missing, **kwargs) 56 57 # Date handling in indexes ---> 58 self._init_dates(dates, freq) 59 60 def _init_dates(self, dates=None, freq=None): ~\Anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py in _init_dates(self, dates, freq) 189 elif freq is not None and index.freq is None: 190 resampled_index = type(index)( --> 191 start=index[0], end=index[-1], freq=freq) 192 if not inferred_freq and not resampled_index.equals(index): 193 raise ValueError('The given frequency argument could' TypeError: __new__() got an unexpected keyword argument 'start'
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。