训练 ARIMA 预测趋势
Training ARIMA to forecast the trend
我正在尝试使用 ARIMA 预测趋势。不幸的是,我得到的输出与预期的输出大不相同(训练和测试数据的行为非常相似)并且表明整个训练数据集好像……没用?
df = pd.read_csv('data.csv')
df.index = pd.DatetimeIndex(df.index).to_period('D')
#data from 1/1/2016 to 31/12/2018
train = df.loc[:'2018-12-31']
test = df.loc['2019-01-01':]
model = auto_arima(train, start_p=1, start_q=1,
max_p=3, max_q=3, m=7,
start_P=0, seasonal=True,
d=1, D=1, trace=True,
error_action='ignore',
suppress_warnings=True,
stepwise=True)
model.aic()
model.fit(train)
ffforecast = model.predict(n_periods=len(test))
ffforecast = pd.DataFrame(fforecast,
index=test.index,
columns=['prediction'])
pd.concat([test, fforecast], axis=1).plot()
pyplot.show()
完整代码:https://pastebin.com/huer62cM
csv: https://filebin.net/rlvm3hrjetlovd64/newbikes6years.csv?t=nt3slw3y
您的模型使用了一组错误的参数。看起来你 copy/pasted 来自不同数据集的示例,它不适合你。
我建议如下:
model = auto_arima(train, error_action='ignore', trace=True, suppress_warnings=True,seasonal=True, maxiter=10, m=7)
根据此输出,您可以在阅读参数并了解它们的作用后返回并优化参数。
我正在尝试使用 ARIMA 预测趋势。不幸的是,我得到的输出与预期的输出大不相同(训练和测试数据的行为非常相似)并且表明整个训练数据集好像……没用?
df = pd.read_csv('data.csv')
df.index = pd.DatetimeIndex(df.index).to_period('D')
#data from 1/1/2016 to 31/12/2018
train = df.loc[:'2018-12-31']
test = df.loc['2019-01-01':]
model = auto_arima(train, start_p=1, start_q=1,
max_p=3, max_q=3, m=7,
start_P=0, seasonal=True,
d=1, D=1, trace=True,
error_action='ignore',
suppress_warnings=True,
stepwise=True)
model.aic()
model.fit(train)
ffforecast = model.predict(n_periods=len(test))
ffforecast = pd.DataFrame(fforecast,
index=test.index,
columns=['prediction'])
pd.concat([test, fforecast], axis=1).plot()
pyplot.show()
完整代码:https://pastebin.com/huer62cM
csv: https://filebin.net/rlvm3hrjetlovd64/newbikes6years.csv?t=nt3slw3y
您的模型使用了一组错误的参数。看起来你 copy/pasted 来自不同数据集的示例,它不适合你。
我建议如下:
model = auto_arima(train, error_action='ignore', trace=True, suppress_warnings=True,seasonal=True, maxiter=10, m=7)
根据此输出,您可以在阅读参数并了解它们的作用后返回并优化参数。