If we serialize randomforest model using joblib on a 64-bit machine, and then unpack on a 32-bit machine, there is an exception:
ValueError: Buffer dtype mismatch, expected 'SIZE_t' but got 'long long'
This question has been asked before: Scikits-Learn RandomForrest trained on 64bit python wont open on 32bit python . But the question has not been answered from since 2014.
Sample code to learn the model (On a 64-bit machine):
modelPath="../"
featureVec=...
labelVec = ...
forest = RandomForestClassifier()
randomSearch = RandomizedSearchCV(forest, param_distributions=param_dict, cv=10, scoring='accuracy',
n_iter=100, refit=True)
randomSearch.fit(X=featureVec, y=labelVec)
model = randomSearch.best_estimator_
joblib.dump(model, modelPath)
Sample code to unpack on a 32-bit machine:
modelPath="../"
model = joblib.load(modelPkl) # ValueError thrown here
My question is: Is there any generic workaround for this problem if we have to learn on a 64-bit machine, and port it to 32-bit machine for prediction?
Edit: Tried to use pickle directly instead of joblib. There are still the same error. The error occurs in the core pickle library (for both joblib and pickle):
File "/usr/lib/python2.7/pickle.py", line 1378, in load
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1133, in load_reduce
value = func(*args)
File "sklearn/tree/_tree.pyx", line 585, in sklearn.tree._tree.Tree.__cinit__ (sklearn/tree/_tree.c:7286)
ValueError: Buffer dtype mismatch, expected 'SIZE_t' but got 'long long'