저장된 SVM 모델을로드하려고하면이 오류가 발생합니다. sklearn, NumPy 및 SciPy를 제거하고 최신 버전을 모두 다시 설치하려고 시도했습니다 (pip 사용). 여전히이 오류가 발생합니다. 왜?
In [1]: import sklearn; print sklearn.__version__
0.18.1
In [3]: import numpy; print numpy.__version__
1.11.2
In [5]: import scipy; print scipy.__version__
0.18.1
In [7]: import pandas; print pandas.__version__
0.19.1
In [10]: clf = joblib.load('model/trained_model.pkl')
---------------------------------------------------------------------------
RuntimeWarning Traceback (most recent call last)
<ipython-input-10-5e5db1331757> in <module>()
----> 1 clf = joblib.load('sentiment_classification/model/trained_model.pkl')
/usr/local/lib/python2.7/dist-packages/sklearn/externals/joblib/numpy_pickle.pyc in load(filename, mmap_mode)
573 return load_compatibility(fobj)
574
--> 575 obj = _unpickle(fobj, filename, mmap_mode)
576
577 return obj
/usr/local/lib/python2.7/dist-packages/sklearn/externals/joblib/numpy_pickle.pyc in _unpickle(fobj, filename, mmap_mode)
505 obj = None
506 try:
--> 507 obj = unpickler.load()
508 if unpickler.compat_mode:
509 warnings.warn("The file '%s' has been generated with a "
/usr/lib/python2.7/pickle.pyc in load(self)
862 while 1:
863 key = read(1)
--> 864 dispatch[key](self)
865 except _Stop, stopinst:
866 return stopinst.value
/usr/lib/python2.7/pickle.pyc in load_global(self)
1094 module = self.readline()[:-1]
1095 name = self.readline()[:-1]
-> 1096 klass = self.find_class(module, name)
1097 self.append(klass)
1098 dispatch[GLOBAL] = load_global
/usr/lib/python2.7/pickle.pyc in find_class(self, module, name)
1128 def find_class(self, module, name):
1129 # Subclasses may override this
-> 1130 __import__(module)
1131 mod = sys.modules[module]
1132 klass = getattr(mod, name)
/usr/local/lib/python2.7/dist-packages/sklearn/svm/__init__.py in <module>()
11 # License: BSD 3 clause (C) INRIA 2010
12
---> 13 from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, \
14 LinearSVR
15 from .bounds import l1_min_c
/usr/local/lib/python2.7/dist-packages/sklearn/svm/classes.py in <module>()
2 import numpy as np
3
----> 4 from .base import _fit_liblinear, BaseSVC, BaseLibSVM
5 from ..base import BaseEstimator, RegressorMixin
6 from ..linear_model.base import LinearClassifierMixin, SparseCoefMixin, \
/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py in <module>()
6 from abc import ABCMeta, abstractmethod
7
----> 8 from . import libsvm, liblinear
9 from . import libsvm_sparse
10 from ..base import BaseEstimator, ClassifierMixin
__init__.pxd in init sklearn.svm.libsvm (sklearn/svm/libsvm.c:10207)()
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 80
UPDATE : 따라 OK, 여기 , 그리고
pip uninstall -y scipy scikit-learn
pip install --no-binary scipy scikit-learn
오류가 발생했지만 왜 처음에 왜 발생했는지 알 수 없습니다 ...
--no-binary
.
pip install --no-binary :all: pandas
. FWIW 나는 신선한에이 오류가 파이썬 버전의 상단에 빌드를 VE 얻고 있었다 Python 3.6.6 :: Anaconda, Inc.
에서만 requests
및 pandas
환경에 설치되어 있어야합니다.
gfortran
scipy를 컴파일 하려면 다음을 설치해야합니다 .sudo apt install gfortran
--no-use-wheel
시스템에있는 모든 것에 대해 소스에서 모듈을 다시 컴파일합니다.