Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于Python中ARIMA模型的家电能耗预测_Python_Prediction_Statsmodels_Arima - Fatal编程技术网

基于Python中ARIMA模型的家电能耗预测

基于Python中ARIMA模型的家电能耗预测,python,prediction,statsmodels,arima,Python,Prediction,Statsmodels,Arima,我有一个由5列组成的数据框,其中第一列是timeseries,其余是单独的设备。这些值是它们在特定时间的能耗 Timestamp KE EH LA PR 0 2013-02-27 00:00:00 1.000000 2.0 0.03 201.289993 1 2013-02-27 00:15:00 0.990000 2.0 0.03 210.070007 2 2013-02-27 00:30:00 0.

我有一个由5列组成的数据框,其中第一列是timeseries,其余是单独的设备。这些值是它们在特定时间的能耗

    Timestamp           KE          EH   LA     PR
0   2013-02-27 00:00:00 1.000000    2.0  0.03   201.289993
1   2013-02-27 00:15:00 0.990000    2.0  0.03   210.070007
2   2013-02-27 00:30:00 0.950000    2.0  0.02   207.779999
3   2013-02-27 00:45:00 0.990000    2.0  0.03   151.960007
4   2013-02-27 01:00:00 0.950000    2.0  0.04   0.000000
... ... ... ... ... ..
我正在使用以下代码创建ARIMA模型:

# Create a copy of the dataset
h3_series = h3_15min.copy()

# Set index
h3_series = h3_series.set_index("Timestamp")

# Verify that the "Timestamp" column is datetime54[ns]
print(h3_series.info())

h3_series.index = h3_series.index.to_period("15min")

# Select 25% of the data
h3_x = h3_series.dropna()
h3_x_25 = int(len(h3_x)/4)
h3_x = h3_x.head(h3_x_25)

# Split into train and test sets
h3_x = h3_x.values
h3_size = int(len(h3_x) * 0.66)
h3_train, h3_test = h3_x[0:h3_size], h3_x[h3_size:len(h3_x)]
h3_history = [x for x in h3_train]
h3_predictions = list()

# Walk-forward validation
for t in range(len(h3_test)):
  h3_ar_1_i_1_ma_1_X = ARIMA(h3_history, order = (1,1,1))
  h3_ar_1_i_1_ma_1_X_fit = h3_ar_1_i_1_ma_1_X.fit()
  h3_output = h3_ar_1_i_1_ma_1_X_fit.forecast()
  h3_yhat = h3_output[0]
  h3_predictions.append(h3_yhat)
  h3_obs = h3_test[t]
  h3_history.append(h3_obs)
当我尝试运行代码时,出现以下错误:

ValueError: endog must be 1-d or 2-d with 1 column
据我所知,这是因为当我只选择KE时,我的模型运行时,数据框必须包含许多设备(KE、EH、LA、PR)。是否可以同时预测多个列的值,而不是单个设备的值?我希望避免创建4个模型来预测每个设备的单个值

感谢您的帮助