首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ARIMA模型预测未来七天

ARIMA模型预测未来七天
EN

Stack Overflow用户
提问于 2021-09-27 00:22:05
回答 1查看 65关注 0票数 0

假设我有一个时间序列,它表示给定日期的股票价格。

代码语言:javascript
复制
stock_price = [10, 15, 23, 24, 24, 23, 25, 25, 33, 30] 

我想构建一个ARIMA模型,该模型能够使用过去三天的价格预测两天后的股价。例如,为了预测stock_price[i+5],它只能使用信息stock_price[i:i+3]

在pandas中,ARIMA采用了三个参数(a,b,c)

代码语言:javascript
复制
model = ARIMA(series, order=(a,b,c))

然而,这些都不是我想要调整的。我不想让ARIMA只预测明天的价格。

EN

回答 1

Stack Overflow用户

发布于 2021-09-28 08:31:42

尝尝这个

代码语言:javascript
复制
# Forecast dataframe - df
n_periods = 7
fc, confint = model.predict(n_periods=n_periods, return_conf_int=True)
index_of_fc = np.arange(len(df.value), len(df.value)+n_periods)

# make series for plotting purpose
fc_series = pd.Series(fc, index=index_of_fc)
lower_series = pd.Series(confint[:, 0], index=index_of_fc)
upper_series = pd.Series(confint[:, 1], index=index_of_fc)

# Plot
plt.plot(df.value)
plt.plot(fc_series, color='darkgreen')
plt.fill_between(lower_series.index, 
                 lower_series, 
                 upper_series, 
                 color='k', alpha=.15)

plt.title("Final Forecast ")
plt.show()

我从这里学到了Arima预测https://www.machinelearningplus.com/time-series/arima-model-time-series-forecasting-python/

这对我很有帮助。希望这也能帮助你解决问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69339968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档