[英]Statsmodels: ARIMA giving less than specified number of predictions
我在时间序列问题上使用ARIMA。 具体来说,我正在使用Sklearn的TimeSeriesSplit
执行交叉验证。 不幸的是,当我要求30时,我得到3个预测。这是我所做的:
Y_train = Y_train.astype(float)
# build basic ARIMA model
arima_model = ARIMA(Y_train, order=(2,0,1))
# fit it
arima_results = arima_model.fit()
# predict next len(test) values
preds = arima_results.forecast(steps=len(Y_test))
print("len of y_train:", len(Y_train))
print("len of y_test:", len(Y_test))
print("len of preds:", len(preds))
我回来了:
len of y_train: 56
len of y_test: 30
len of preds: 3
当我去计算mean_squared_error
时,这会导致错误,因为预测的长度(3)与测试集(30)的长度不同。 这是错误:
ValueError: Found input variables with inconsistent numbers of samples: [3, 30]
知道我在玩什么吗?
谢谢!
fit
从文档中返回ARIMAResults
实例,该实例提供了forecast
方法。
返回值是一个tuple
,其中每个元素都是一个适当长度的数组,具有不同类型的结果计算。 所以看来您想使用
preds[0]
而不是直接看preds
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.