Submitted by ng_guardian t3_11or4qb in MachineLearning

I trained my ARIMA model by doing the following

from statsmodels.tsa.arima.model import ARIMA

model_ar = ARIMA(data.Num_Passengers, order=(1,0, 0))

results_ar = model_ar.fit()results_ar.summary()

​

The code worked with the resulting output

​

https://preview.redd.it/zi8f1lhak5na1.png?width=746&format=png&auto=webp&v=enabled&s=3f5ef9fe1504892e4ce48b5287d8b834f1dfdb27

But then I tried predicting on the testing dataset, and I got the following error.

​

https://preview.redd.it/uni7ws1ck5na1.png?width=1675&format=png&auto=webp&v=enabled&s=ce520334f3b1e420a101adda9f43868714617272

Am I just messing something up, is anyone else dealing with this error?

Is there another way to use the predict function, or is it really unimplemented.

Could you please help me out with this?

How would I overwrite the method?

0

Comments

You must log in or register to comment.

Toilet_Assassin t1_jbujz0i wrote

Read the documentation, you are using it incorrectly.

1

ng_guardian OP t1_jbuwfbd wrote

How do I overwrite it? That is all the documentation says

1

Toilet_Assassin t1_jbva7zk wrote

Try googling 'statsmodels predict' and pay attention to which object the .predict() method is called from.

1

Affectionate_Shine55 t1_jbvqc9r wrote

model_ar.fit().predict(test)

Usually people do

res=model_ar.fit()

res.summary()

preds = res.predict(test)

1

TywinASOIAF t1_jby3znl wrote

Python statmodels is bad. It cannot handle hour data for example. Use R if you do time series.

1

Toilet_Assassin t1_jbz6bjm wrote

What do you mean when you say it can't handle hour data? I haven't ran into any issues with it as of yet.

3

TywinASOIAF t1_jbzbm13 wrote

You have to make very weird code in Pandas to handle data on hour intervals (15:00, 16:00, 17:00 etc) with statmodels. In R this is no issue. Convert to tsibble and you are good to go.

1

Toilet_Assassin t1_jc0gn35 wrote

In the end the observations you feed to the model will boil down to a sequentially indexed array, so it isn't too much effort to map indices to hour intervals with a time column. You will have to extend the time column to match the forecasted indices though, but that isn't too much effort at the end of the day.

3