ARIMA Forecast: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
Asked Answered
D

1

8

I am using ARIMA to fit values and save it as a pickle file. Post that, the pickle file is used to get out of sample predictions. However, while getting sample predictions I am getting the following error: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'.

def forecast_fit(df):            
  series=df
  X = series.values
  train=X
  model = ARIMA(X, order=(1,0,1))
  model_fit = model.fit(disp=0)
  model_fit.save('model.pkl')
forecast_fit(df)
#Out of sample forecasts
loaded = ARIMAResults.load('model.pkl)
forecast = loaded.forecast(steps=17)[0]        #error_occurs_here
df=pd.DataFrame(forecast, columns=[i+'_hat'])  

The df contains the following data: https://docs.google.com/spreadsheets/d/14W77ra-nQYqvDN8wSPhhiN11lBnob6ZW0UVevQ5orKk/edit?usp=sharing

I am attaching the data because the error occurs with this very sample, rest of the variables(I am repeating the exercise for many other variables) don't produce the error.

Domitiladomonic answered 1/6, 2018 at 15:59 Comment(1)
The error seems to be some datatype mismatch, but it should reflect while fitting the model and not while getting out of sample predictions.Domitiladomonic
D
13

It appears statsmodels ARIMA throws error because it doesn't explicitly converts int to float. If I try to convert data to float, statsmodels will work well.

X = X.astype('float32')

This is already a reported bug on Github.

Domitiladomonic answered 6/6, 2018 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.