你好,我尝试进行时间序列分析,但是我得到了回溯,有人可以帮助我吗?
Python版本:3.6.7
数据集:https://www.kaggle.com/neuromusic/avocado-prices
# ARIMA LİBRARY
from statsmodels.tsa.arima_model import ARIMA
from pandas import datetime
# fit model
model = ARIMA(ts, order=(1,0,1)) # (ARMA) = (1,0,1)
model_fit = model.fit(disp=0)
# predict
start_index = datetime(2015, 1, 4)
end_index = datetime(2018, 3, 25)
forecast = model_fit.predict(start=start_index, end=end_index)
# visualization
plt.figure(figsize=(22,10))
plt.plot(data.date,data.avprice,label = "original")
plt.plot(forecast,label = "predicted")
plt.title("Time Series Forecast")
plt.xlabel("Date")
plt.ylabel("Mean Temperature")
plt.legend()
plt.show()
跟踪:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-277-17297527abe9> in <module>()
10 start_index = datetime(2015, 1, 4)
11 end_index = datetime(2018, 3, 25)
---> 12 forecast = model_fit.predict(start=start_index, end=end_index)
13
14 # visualization
TypeError: unsupported operand type(s) for -=: 'slice' and 'int'