Reputation: 4575
I developed the code below on my mac and it ran fine. I run the code in a jupyter notebook with anaconda and the python version below. Everything runs fine and saves the pickle file correctly on my mac. When I try to share the same code with my friend and he runs it on his windows machine with the version info below. He gets the error below. Everything in the code runs fine except the step where he saves the pickle file. He is also running it in a jupyter notebook. All the ARIMA code runs fine, it's just saving the model to a pickle file that's throwing the error. Does anyone know what the issue might be and can you suggest a solution? Any tips greatly appreciated.
Mac info:
statsmodel: 0.9.0
python: 3.6.5
macOS Sierra version 10.12.6
Windows info Version:
statswisemodel: 0.9.0
python : 3.6.3
Win10 machine
RAM: 16GB
Code:
import numpy as np
import pandas as pd
from time import time
import scipy.stats as stats
from IPython.display import display # Allows the use of display() for DataFrames
# Pretty display for notebooks
%matplotlib inline
import glob
import matplotlib.pyplot as plt
Code:
stepwise_model
Output:
ARIMA(callback=None, disp=0, maxiter=50, method=None, order=(1, 1, 3),
out_of_sample_size=0, scoring='mse', scoring_args={},
seasonal_order=(2, 1, 2, 12), solver='lbfgs', start_params=None,
suppress_warnings=True, transparams=True, trend='c')
# saving stepwise_model to pickle file
import pickle
your_data = stepwise_model
# stepwise_model data (serialize)
with open('stepwise_model.pickle', 'wb') as handle:
pickle.dump(your_data, handle, protocol=pickle.HIGHEST_PROTOCOL)
TypeError Traceback (most recent call last)
<ipython-input-21-cee2e10d7185> in <module>()
6 # stepwise_model data (serialize)
7 with open('stepwise_model.pickle', 'wb') as handle:
----> 8 pickle.dump(your_data, handle, protocol=pickle.HIGHEST_PROTOCOL)
~\Anaconda3\lib\site-packages\pyramid\arima\arima.py in __getstate__(self)
476 # https://github.com/statsmodels/statsmodels/issues/3290
477 self.arima_res_.summary()
--> 478 self.arima_res_.save(fname=new_loc) # , remove_data=False)
479
480 # point to the location of the saved MLE model
~\Anaconda3\lib\site-packages\statsmodels\base\wrapper.py in save(self, fname, remove_data)
70 self.remove_data()
71
---> 72 save_pickle(self, fname)
73
74 @classmethod
~\Anaconda3\lib\site-packages\statsmodels\iolib\smpickle.py in save_pickle(obj, fname)
13 """
14 with get_file_obj(fname, 'wb') as fout:
---> 15 cPickle.dump(obj, fout, protocol=-1)
16
17
TypeError: can't pickle statsmodels.tsa.statespace._statespace.dStatespace objects
Upvotes: 0
Views: 550
Reputation: 71
def __getnewargs__(self):
return ((self.endog),(self.k_lags, self.k_diff, self.k_ma))
ARIMA.__getnewargs__ = __getnewargs__
Upvotes: 0