Wrong dates when doing prediction with ARMA model
Hello,
I was trying out the library and fit a simple ARMA(4, 4) model. I tried running predictions and it seems the dates of the output are completely wrong.
In [51]: model.predict(1)
Out[51]:
training
2025-01-26 09:00:00 230.533628
In [52]: model.predict(2)
Out[52]:
training
2034-12-05 08:00:00 230.533628
2034-12-05 09:00:00 227.872326
In [53]: model.predict(3)
Out[53]:
training
2044-10-13 07:00:00 230.533628
2044-10-13 08:00:00 227.872326
2044-10-13 09:00:00 228.856676
Is is a known bug or I did something wrong ?
Taking a look at this today!
Is this issue not fixed? It still seems to be an open bug....:)
how to fix this issue ? it seems that pro has not been solved, as now it's still backward prediction when using model.predict()
Hi, any news on this one?
I believe I found where the bug lies. The method shift_dates of the TSM class is currently not working with pandas datetime index. The code on line 541
(date_index[len(date_index)-1] - date_index[len(date_index)-2]).seconds
will always return the number of seconds in the timedelta object (by documentation >= 0 and < 1 day), not the number of total seconds between the dates. To fix it just simply use:
date_index += pd.DateOffset(seconds=(date_index[len(date_index)-1] - date_index[len(date_index)-2]).total_seconds())
@ryshoooo 's solution is spot on and worked for me. Only thing is that we have to change the code from line 538:
if pd.infer_freq(date_index) in ['H', 'M', 'S',]:
to
if pd.infer_freq(date_index)[-1] in ['H', 'M', 'S','T']: