Issue 1:
I am using sklearn for my project i have trained model on 64 bit linux machine,now i want to load that model (.pickle format) on raspberry pi which is 32 bit os and hw configuration,i have following issue while unpickling model file.

Please help me if any solution on this.

knn_clf =joblib.load(f)

File "/usr/local/lib/python3.5/dist-packages/sklearn/externals/joblib/numpy_pickle.py", line 568, in load

obj = _unpickle(fobj)

File "/usr/local/lib/python3.5/dist-packages/sklearn/externals/joblib/numpy_pickle.py", line 508, in _unpickle

obj = unpickler.load()

File "/usr/lib/python3.5/pickle.py", line 1043, in load

dispatchkey[0]

File "/usr/local/lib/python3.5/dist-packages/sklearn/externals/joblib/numpy_pickle.py", line 328, in load_build

Unpickler.load_build(self)

File "/usr/lib/python3.5/pickle.py", line 1518, in load_build

setstate(state)

File "sklearn/neighbors/binary_tree.pxi", line 1128, in sklearn.neighbors.ball_tree.BinaryTree.setstate

File "sklearn/neighbors/binary_tree.pxi", line 228, in sklearn.neighbors.ball_tree.get_memview_ITYPE_1D

ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long long'

Issue 2:
Description

ValueError: Did not recognise loaded array layout thrown when loading model pickled in 32 bit Linux and loaded on 32 bit Windows. The reverse is also true. Models can be pickled/loaded on their respective OS so it seems to be a cross-platform issue.

I've tried both joblib and pickle and ensured that library versions are the same on Windows and Linux. Libraries were obtained using miniconda from the anaconda channel using libraries uploaded by @kalefranz (https://anaconda.org/anaconda/scikit-learn)

Seems similar to #6650. 64 bit models are able to load. However, 32 bit is a requirement for my use case.

Steps/Code to Reproduce

Minimum code to reproduce

create_model.py

from sklearn.externals import joblib
import numpy as np
from sklearn.ensemble import RandomForestClassifier
import pickle

X = np.random.randn(1500,8)
l = np.random.randint(6, size = 1500)
clf_forest = RandomForestClassifier(n_estimators = 10)
clf_forest.fit(X,l)
joblib.dump(clf_forest,'joblib_clf_forest_win.pkl')

with open('pickle_clf_forest_win.pkl', 'wb') as f:
pickle.dump(clf_forest, f)

pickle_load.py

import pickle

with open('pickle_clf_forest.pkl', 'rb') as f:
pickle.load(f)

joblib_load.py

from sklearn.externals import joblib

a = joblib.load('joblib_clf_forest.pkl')

Expected Results

No error is thrown.

Actual Results

(..\exe\virtualenvs\32-sklearn0191)$ python joblib_load.py
Windows-7-6.1.7601-SP1
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 14:16:49) [MSC v
.1900 32 bit (Intel)]
NumPy 1.13.3
SciPy 0.19.1
Scikit-Learn 0.19.1
Traceback (most recent call last):
File "joblib_load.py", line 9, in <module>
a = joblib.load('joblib_clf_forest.pkl')
File "virtualenvs\32-sklearn0191\lib\site-packages\sklear
n\externals\joblib\numpy_pickle.py", line 578, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "virtualenvs\32-sklearn0191\lib\site-packages\sklear
n\externals\joblib\numpy_pickle.py", line 508, in _unpickle
obj = unpickler.load()
File "virtualenvs\32-sklearn0191\lib\pickle.py", line 105
0, in load
dispatch[key[0]](self)
File "virtualenvs\32-sklearn0191\lib\site-packages\sklear
n\externals\joblib\numpy_pickle.py", line 328, in load_build
Unpickler.load_build(self)
File "virtualenvs\32-sklearn0191\lib\pickle.py", line 150
8, in load_build
setstate(state)
File "sklearn\tree\_tree.pyx", line 667, in sklearn.tree._tree.Tree.__setstate
__
ValueError: Did not recognise loaded array layout

(..\exe\virtualenvs\32-sklearn0191) $ python pickle_load.py
Windows-7-6.1.7601-SP1
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 14:16:49) [MSC v
.1900 32 bit (Intel)]
NumPy 1.13.3
SciPy 0.19.1
Scikit-Learn 0.19.1
Traceback (most recent call last):
File "pickle_load.py", line 10, in <module>
pickle.load(f)
File "sklearn\tree\_tree.pyx", line 667, in sklearn.tree._tree.Tree.__setstate
__
ValueError: Did not recognise loaded array layout

Versions

Windows 32 conda environment:

Windows-7-6.1.7601-SP1
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 14:16:49) [MSC v
.1900 32 bit (Intel)]
NumPy 1.13.3
SciPy 0.19.1
Scikit-Learn 0.19.1

# packages in environment at virtualenvs\32-sklearn0191:
#
altgraph 0.14 <pip>
appdirs 1.4.0 <pip>
certifi 2016.2.28 py36_0
certifi 2017.11.5 <pip>
chardet 3.0.4 <pip>
future 0.16.0 <pip>
icc_rt 2017.0.4 h97af966_0 anaconda
idna 2.6 <pip>
intel-openmp 2018.0.0 hda8db3e_7 anaconda
macholib 1.8 <pip>
mkl 2018.0.0 hd024497_4 anaconda
mock 2.0.0 <pip>
numpy 1.13.3 py36h38e73f1_0 anaconda
packaging 16.8 <pip>
pandas 0.20.3 py36h93e7217_2 anaconda
pandas 0.20.3 <pip>
pbr 3.1.1 <pip>
pefile 2017.9.3 <pip>
pip 9.0.1 py36_1
psycopg2 2.7.3.2 <pip>
PyInstaller 3.3 <pip>
pyparsing 2.2.0 <pip>
pypiwin32 220 <pip>
python 3.6.1 2
python-dateutil 2.6.1 py36h507c767_1 anaconda
python-dateutil 2.6.1 <pip>
python-magic 0.4.5 <pip>
pytz 2017.3 <pip>
pytz 2017.2 py36h6ca8096_1 anaconda
PyYAML 3.12 <pip>
requests 2.18.4 <pip>
scikit-learn 0.19.1 py36hb0057d7_0 anaconda
scipy 0.19.1 py36hfc7e94f_3 anaconda
setuptools 36.4.0 py36_1
six 1.11.0 py36h7f2c006_1 anaconda
six 1.11.0 <pip>
SQLAlchemy 1.1.15 <pip>
urllib3 1.22 <pip>
vc 14 0
vs2015_runtime 14.0.25420 0
wheel 0.29.0 py36_0
wincertstore 0.2 py36_0
XlsxWriter 0.9.6 <pip>

Linux 32 bit environment

Dockerfile

FROM continuumio/miniconda3

RUN apt-get update \
&& apt-get install -y libc6-i386 lib32stdc++6 python3-dev gcc libmagic-dev

RUN CONDA_FORCE_32BIT=1 conda create -n 32

Linux-4.9.49-moby-x86_64-with-debian-8.9
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:08:54)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.13.3
SciPy 0.19.1
Scikit-Learn 0.19.1

boto3 1.4.4 <pip>
botocore 1.5.95 <pip>
ca-certificates 2017.08.26 h1d4fec5_0
certifi 2017.7.27.1 py36h3f8508d_0
chardet 3.0.4 <pip>
docutils 0.14 <pip>
future 0.16.0 <pip>
idna 2.6 <pip>
imbalanced-learn 0.3.1 <pip>
intel-openmp 2018.0.0 h76c16ec_7 anaconda
Jinja2 2.9.6 <pip>
jmespath 0.9.3 <pip>
libgcc-ng 7.2.0 h7cc24e2_2
libgfortran-ng 7.2.0 h9f7466a_2 anaconda
libstdcxx-ng 7.2.0 h7a57d05_2 anaconda
MarkupSafe 1.0 <pip>
mkl 2018.0.0 haa892f1_4 anaconda
numpy 1.13.3 py36hde72de1_0 anaconda
openssl 1.0.2m h7e5a0c8_0
pandas 0.20.3 py36hd73fee5_2 anaconda
pefile 2017.9.3 <pip>
pip 9.0.1 py36hdf7ad74_4
psycopg2 2.7.3 <pip>
python 3.6.1 2
python-dateutil 2.6.1 py36h0ec02a2_1 anaconda
python-dateutil 2.6.1 <pip>
python-magic 0.4.13 <pip>
pytz 2017.2 py36hbc70297_0 anaconda
raven 6.3.0 <pip>
readline 6.2 2
requests 2.18.4 <pip>
s3transfer 0.1.11 <pip>
scikit-learn 0.19.1 py36h4fdfdbb_0 anaconda
scipy 0.19.1 py36hc385b52_3 anaconda
setuptools 36.5.0 py36h9e9eae1_0
six 1.11.0 py36hd5049a8_1 anaconda
six 1.11.0 <pip>
sqlite 3.13.0 0
tk 8.5.18 0
urllib3 1.22 <pip>
vtservices 1.1.0 <pip>
wheel 0.29.0 py36h1274d80_1
xz 5.2.3 ha3e1f4e_2
zlib 1.2.11 h907e355_2