SARIMAX 没有结果
No result for SARIMAX
我正在开展一个项目来分析 covid 19 如何影响出货量,我正在使用 SARIMAX 来预测未来几个月的出货量。但是,我不断得到如下所示的结果:
# Shipment volume data (monthly basis)
df_monthly = df.loc[:'2020-06-30'].resample('MS').sum()
df_monthly
# covid 19 data (monthly basis)
df_covid_monthly = df_covid.loc[:'2020-06-30']
df_covid_monthly = df_covid.resample('MS').sum()
df_covid_monthly
# SARIMAX model
model= SARIMAX(df_monthly, exog=df_covid_new, order=(2,1,1), enforce_invertibility=False,
enforce_stationarity=False)
results= model.fit()
# Prediction
pred = results.get_prediction(start='2020-06-01',end='2020-12-01',dynamic=False, index=None,
exog=df_covid_monthly['2020-02-01':],
extend_model=None, extend_kwargs=None)
pred
输出:
<statsmodels.tsa.statespace.mlemodel.PredictionResultsWrapper at 0x27b64b4a608>
这是预期的输出。您需要访问 PredictionResultsWrapper
的属性,例如 predicted_mean
.
查看开发文档:https://www.statsmodels.org/devel/generated/statsmodels.tsa.base.prediction.PredictionResults.html
请注意,您不会看到 Wrapper
,因为这只是一个附加索引并进行管理的 class。 PredictionResults
是返回的主要 class。
经过多次阅读和修改我的代码的尝试,我终于能够得到我的预测结果。这是我所做的更改:
model = sm.tsa.SARIMAX(endog=df_monthly, order=(1,1,1),seasonal_order=(0,1,1,12))
model_fit = model.fit()
prediction = model_fit.predict(start='2020-07-01',end='2020-1201',dynamic=False, exog=df_covid_monthly,extend_kwargs=None)
我正在开展一个项目来分析 covid 19 如何影响出货量,我正在使用 SARIMAX 来预测未来几个月的出货量。但是,我不断得到如下所示的结果:
# Shipment volume data (monthly basis)
df_monthly = df.loc[:'2020-06-30'].resample('MS').sum()
df_monthly
# covid 19 data (monthly basis)
df_covid_monthly = df_covid.loc[:'2020-06-30']
df_covid_monthly = df_covid.resample('MS').sum()
df_covid_monthly
# SARIMAX model
model= SARIMAX(df_monthly, exog=df_covid_new, order=(2,1,1), enforce_invertibility=False,
enforce_stationarity=False)
results= model.fit()
# Prediction
pred = results.get_prediction(start='2020-06-01',end='2020-12-01',dynamic=False, index=None,
exog=df_covid_monthly['2020-02-01':],
extend_model=None, extend_kwargs=None)
pred
输出:
<statsmodels.tsa.statespace.mlemodel.PredictionResultsWrapper at 0x27b64b4a608>
这是预期的输出。您需要访问 PredictionResultsWrapper
的属性,例如 predicted_mean
.
查看开发文档:https://www.statsmodels.org/devel/generated/statsmodels.tsa.base.prediction.PredictionResults.html
请注意,您不会看到 Wrapper
,因为这只是一个附加索引并进行管理的 class。 PredictionResults
是返回的主要 class。
经过多次阅读和修改我的代码的尝试,我终于能够得到我的预测结果。这是我所做的更改:
model = sm.tsa.SARIMAX(endog=df_monthly, order=(1,1,1),seasonal_order=(0,1,1,12))
model_fit = model.fit()
prediction = model_fit.predict(start='2020-07-01',end='2020-1201',dynamic=False, exog=df_covid_monthly,extend_kwargs=None)