【发布时间】:2022-11-19 02:31:35
【问题描述】:
我有一个包含 100 行和 1000 多列的时间序列数据框。这些列彼此独立。我在每一列上运行 ARIMA 模型。所以,这就像运行 1000+ ARIMA 分析。
我编写了一段代码,循环遍历训练集的列,并根据提供的 p、d、q 参数在每一列上拟合 ARIMA 模型。虽然,看起来随着模型进一步训练列,它忘记了之前学到的东西,只使用最后训练的列的训练结果来预测测试。 (这导致预测在测试集上过度拟合)。
有没有一种方法可以将所有经过训练的模型的学习结合在一起,并用它来对我的测试集进行预测?
示例数据框如下所示:
date Col 1 Col 2 Col 3 Col 4
2001-07-21 10:00:00+05:00 45 51 31 3
2001-07-21 10:15:00+05:00 46 50 32 3
2001-07-21 10:30:00+05:00 47 51 34 7
2001-07-21 10:45:00+05:00 50 50 33 9
2001-07-21 11:00:00+05:00 55 51 32 8
2001-07-21 11:15:00+05:00 52 73 34 11
2001-07-21 11:30:00+05:00 51 72 30 14
我实现的代码是:
#training set inclues all columns except the last and test set includes only last column.
train = df.iloc[:, :-1]
test = df.iloc[:,-1:]
order = (1,2,3) # <- plug-in p, d, q here
for col in train.columns:
model = ARIMA(train[col], order = order) #training every column in training set
model = model.fit()
model.summary()
predictions = model.predict(len(test))
【问题讨论】:
标签: python pandas machine-learning model