python - 类型错误 : predict() missing 1 required positional argument: 'params'

标签 python python-3.x dataframe time-series

我建立了一个时间序列模型并尝试预测结果

model = ARIMA(df_mat.Total_Issue_quantities, order=(5,0,0))

y_predict_log = model.predict(start=1, end=24, exog=None, dynamic=False)

最佳答案

为了使用 statsmodels 包中的 ARIMA 模型,您必须在使用它进行预测之前拟合模型。

考虑样本时间序列数据,

series = [266, 145.9, 183.1, 119.3, 180.3, 168.5, 231.8, 224.5, 192.8, 122.9, 336.5, 185.9, 194.3, 149.5, 210.1, 273.3, 191.4, 287,
226, 303.6, 289.9, 421.6, 264.5, 342.3, 339.7, 440.4, 315.9, 439.3, 401.3, 437.4, 575.5, 407.6, 682, 475.3, 581.3, 646.9]

为了在 statsmodelsARIMA 帮助下进行预测,您必须定义模型并像这样拟合它,

model = ARIMA(series, order=(5,0,0))
model_fit = model.fit(disp=0)

然后你必须使用拟合模型来做出这样的预测,

model_fit.predict(start=1, end=24, exog=None, dynamic=False)

# Output : array([285.26079759, 241.67873214, 188.09176114, 172.71030303,
       151.02883535, 171.42694684, 187.24591603, 222.14251879,
       231.60804343, 200.38894148, 165.46244686, 276.73489965,
       234.58863518, 189.25204514, 175.23997131, 207.32713479,
       259.00583598, 226.21898223, 261.36238407, 255.73519862,
       285.57681894, 310.52631127, 376.59078703, 314.29265595])

关于python - 类型错误 : predict() missing 1 required positional argument: 'params' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55720384/

相关文章:

python - 或者条件和for循环不好用?

python - 如何reshape()numpy中奇数行和偶数行的总和

python - Pandas Dataframe检查id在时间间隔内是否出现大于1

python - Pandas 中的列到行

linux - 如何在任何 linux 发行版中找到 python 包名称?

python - Pandas - 为什么分块 'on' 的 read_csv 比没有分块的小文件更快?

python - 检查字符串但跳过括号内的数字?

python - IDLE Python/PIL 模块 - 默认图像查看器

python - 在 MultiIndex 上使用 between_time()?

python-3.x - Elasticsearch中的通配符搜索-Python