Reputation: 301
I am trying to make prediction on my ARIMA Model but I'm stuck in one point
from statsmodels.tsa.arima.model import ARIMA
train2 = trainData1["meantemp"][:1170]
test2 = trainData1["meantemp"][1170:]
# p,d,q ARIMA Model
model = ARIMA(train2, order=(1,1,50))
model_fit = model.fit()
print(model_fit.summary())
Here, trainData1 has date as index (both train2 and test2) and trained model with train2 data, after that I tried to make prediction on test2 data as follows:
# make predictions
predictions = model_fit.predict(test2)
rmse = mean_squared_error(test2.values, predictions)
rmse
But it gives me the following error ;
TypeError: Cannot convert input [date
2016-03-17 2.375000
2016-03-18 -0.125000
2016-03-19 0.598214
2016-03-20 0.347619
2016-03-21 -0.508333
...
2016-12-28 0.367391
2016-12-29 -1.979296
2016-12-30 -1.142857
2016-12-31 0.957393
2017-01-01 -5.052632
Name: meantemp, Length: 291, dtype: float64] of type <class 'pandas.core.series.Series'> to Timestamp
What should be added to inside of predict function as data ?
train2 as follows:
2013-01-02 -2.600000
2013-01-03 -0.233333
2013-01-04 1.500000
2013-01-05 -2.666667
2013-01-06 1.000000
...
2016-03-12 -0.504167
2016-03-13 -0.312500
2016-03-14 -1.875000
2016-03-15 1.691667
2016-03-16 -0.129167
Name: meantemp, Length: 1170, dtype: float64
test2 as follows:
date
2016-03-17 2.375000
2016-03-18 -0.125000
2016-03-19 0.598214
2016-03-20 0.347619
2016-03-21 -0.508333
...
2016-12-28 0.367391
2016-12-29 -1.979296
2016-12-30 -1.142857
2016-12-31 0.957393
2017-01-01 -5.052632
Name: meantemp, Length: 291, dtype: float64
Upvotes: 3
Views: 8478
Reputation: 301
I solved my own problem as follows ;
# make predictions
predictions = model_fit.forecast(291)
print(f'ARIMA Model Test Data MSE: {np.mean((predictions.values - test2.values)**2):.3f}')
with forecast function , model predicted next 291 step which is day here as it is daily time-series and made evaluation with MSE metric using predictions and actual test values.
Upvotes: 4