SARIMAX没有结果

2024-06-07 15:41:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个项目,分析新冠病毒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> 

Tags: nonefalsedfdatamodelbasislocms
2条回答

这是预期的输出。您需要访问PredictionResultsWrapper的属性,例如predicted_mean

请参阅开发文档:https://www.statsmodels.org/devel/generated/statsmodels.tsa.base.prediction.PredictionResults.html

请注意,您不会看到Wrapper,因为这只是一个附加索引并执行内务管理的类PredictionResults是返回的主类

经过多次阅读和修改代码的尝试,我终于能够得到预测的结果。以下是我所做的更改:
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)

相关问题 更多 >

    热门问题