【问题标题】:ARIMA model predicting seven days in the futureARIMA 模型预测未来 7 天
【发布时间】:2021-09-27 00:22:04
【问题描述】:

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

stock_price = [10, 15, 23, 24, 24, 23, 25, 25, 33, 30] 

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

在 pandas 中,ARIMA 接受三个参数(a,b,c)

model = ARIMA(series, order=(a,b,c))

但是,这些都不是我想要调整的。我不希望 ARIMA 仅仅预测明天的价格。

【问题讨论】:

  • 您能否发布您的整个代码,尤其是 ARIMA 模型的创建和相应的导入?我不认为您使用 ARIMA 的 pandas 实现。你确定不使用 statsmodels 吗?

标签: python pandas arima


【解决方案1】:

试试这个

# 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/
这对我有帮助。希望这也有助于解决您的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-10
    • 2020-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 2016-06-06
    • 1970-01-01
    相关资源
    最近更新 更多