現在、pmdarima の Auto_ARIMA を使用して、予測値と予測信頼区間を出力として時系列予測モデルを適合させようとしています。しかし、信頼区間の出力を pandas データフレームに割り当てようとすると、いくつかのエラーが発生します。コードとエラーは次のとおりです。
import numpy as np
import pandas as pd
from pmdarima import auto_arima
model = auto_arima(train,
exogenous=df_train[exogenous_features],
start_p=1, start_q=1, d=n_adf, max_p=5, max_q=5,
trace=True, n_jobs = -1, error_action="ignore", suppress_warnings=True)
model.fit(train,
exogenous=df_train[exogenous_features])
forecast, confint = model.predict(n_periods=len(df_valid),
return_conf_int=True, alpha=0.05,
exogenous=df_valid[exogenous_features])
df_valid["Forecast_ARIMA"] = forecast
df_valid["Upper", "Lower"] = confint
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2897 try:
-> 2898 return self._engine.get_loc(casted_key)
2899 except KeyError as err:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: ('Upper', 'Lower')
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
8 frames
KeyError: ('Upper', 'Lower')
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/internals/blocks.py in __init__(self, values, placement, ndim)
129 if self._validate_ndim and self.ndim and len(self.mgr_locs) != len(self.values):
130 raise ValueError(
--> 131 f"Wrong number of items passed {len(self.values)}, "
132 f"placement implies {len(self.mgr_locs)}"
133 )
ValueError: Wrong number of items passed 2, placement implies 1
誰かがこれについて私を助けることができれば本当に感謝しています、どうもありがとう