假设我有一个时间序列,它表示给定日期的股票价格。
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)
model = ARIMA(series, order=(a,b,c))然而,这些都不是我想要调整的。我不想让ARIMA只预测明天的价格。
发布于 2021-09-28 08:31:42
尝尝这个
# 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/
这对我很有帮助。希望这也能帮助你解决问题
https://stackoverflow.com/questions/69339968
复制相似问题