English 中文(简体)
使用 arima 预测但显示 Python 错误
原标题:Prediction using arima but showing error in Python

用来预测商店销售量的阿利马模型 使用Stats models.tsa.arima. model. Arima模型来预测商店销售量

from statsmodels.tsa.arima.model import ARIMA
from datetime import datetime

# fit model
model = ARIMA(ts, order=(1,0,1)) 
model_fit = model.fit()

# predict
start_index = datetime(2024, 1, 1)
end_index = datetime(2024, 5, 1)
# model_fit.predict(start=start_index, end=end_index)
forecast = model_fit.predict(start = "2024-01-01", end = "2024-05-01")

However, it just shows ValueError: Prediction must have `end` after `start`. Is there anyone having the same issue as well?

ts is a dataframe with two columns, date(index, from 2021/01/01 to 2024/05/02) and gmv

date          gmv
2021-01-01    155629555
2021-01-02    161346990
...
...
2024-01-01    192776022
...
2024-05-01    207816942
2024-05-02    217788026
问题回答

确保正确定义 t 和日期范围。 在此情况下, 您需要以与时间序列索引兼容的格式为预测函数提供起始和结束参数 。





相关问题
Get webpage contents with Python?

I m using Python 3.1, if that helps. Anyways, I m trying to get the contents of this webpage. I Googled for a little bit and tried different things, but they didn t work. I m guessing that this ...

What is internal representation of string in Python 3.x

In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16? The items ...

What does Python s builtin __build_class__ do?

In Python 3.1, there is a new builtin function I don t know in the builtins module: __build_class__(...) __build_class__(func, name, *bases, metaclass=None, **kwds) -> class Internal ...

what functional tools remain in Python 3k?

I have have read several entries regarding dropping several functional functions from future python, including map and reduce. What is the official policy regarding functional extensions? is lambda ...

Building executables for Python 3 and PyQt

I built a rather simple application in Python 3.1 using PyQt4. Being done, I want the application to be distributed to computers without either of those installed. I almost exclusively care about ...

热门标签