I´m predicting the prices for a good in 5 regions. The data is organized as a Pandas data frame.
When I run autoARIMA for each column apart, it is fine (eg, for data_frame["Region_name"]
).
def __trainArima(self, actual_values, periods):
fitted_model = pm.auto_arima(actual_values, start_p=3,
start_q=2,
max_p=3, max_q=3, m=12,
start_P=0, seasonal=True,
d=1, D=1, trace=True,
error_action='ignore',
suppress_warnings=True,
stepwise=True)
return fitted_model.predict(n_periods=periods)
__trainArima(data_frame, 12)
However, I want to run it at once for all the 5 columns, having an output as a data frame of 5 columns for each region of predictions for the next 12 month. Is that possible?
如果您不相信自己的列是相关的,则可以遍历每个列并运行ARIMA,然后合并预测。
To elaborate, you could loop though like this:
import pandas as pd
results = []
cols = []
for i in data_frame.columns:
cols.append(i)
result = __trainArima(test[i])
results.append(result)
output = (pd.DataFrame(results)).T
output.columns=cols
that will output a data frame with your predictions under the same column names as they appear in the original dataframe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.