gpt4 book ai didi

python - ValueWarning : No frequency information was provided, 因此将使用推断频率 MS

转载 作者:太空狗 更新时间:2023-10-29 21:48:23 24 4
gpt4 key购买 nike

我尝试通过 sm.tsa.statespace.SARIMAX 拟合自回归。但是我遇到一个警告,然后我想为这个模型设置频率信息。谁曾经见过它,你能帮帮我吗?

fit1 = sm.tsa.statespace.SARIMAX(train.Demand, order=(1, 0, 0), 
enforce_stationarity=False,
enforce_invertibility=False).fit()
y_hat['AR'] = fit1.predict(start="1975-01-01", end="1975-12-01", dynamic=True)
plt.figure(figsize=(16,8))
plt.plot( train['Demand'], label='Train')
plt.plot(test['Demand'], label='Test')
plt.plot(y_hat_avg['AR'], label='AR')
plt.legend(loc='best')
plt.show()

C:\Users\thach.le\Anaconda3\lib\site-packages\statsmodels-0.8.0-py3.6-win-
amd64.egg\statsmodels\tsa\base\tsa_model.py:165: ValueWarning: No frequency
information was provided, so inferred frequency MS will be used.
% freq, ValueWarning)

谢谢

最佳答案

如果您的数据确实是周期性的,并且您的时间序列中没有间隙,那么 pandas 可以推断出频率。

如果您认为推断的频率正确,您可以按照 Set pandas.tseries.index.DatetimeIndex.freq with inferred_freq 中的答案使用它。

例如

train.index = pd.DatetimeIndex(train.index.values,
freq=train.index.inferred_freq)
fit1 = sm.tsa.statespace.SARIMAX(...)

但请注意,如果您的数据不是真正的周期性数据,这仍然可以给出频率为 NoneDatetimeIndex

例如,如果您有每日数据并且缺少一天,则 inferred_freq 将为 None 并尝试通过 freq="D" 将引发 ValueError 异常。在这种情况下,请尝试构建您的 DataFrame,以便所有日期都存在,并且您预测的列中的值在这些日期为 None。然后,您可以将 missing="drop"(或其他)与您的 ARIMA 模型一起使用。

关于python - ValueWarning : No frequency information was provided, 因此将使用推断频率 MS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49547245/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com