我正在尝试使用scikit-learn svm根据主题对电子邮件进行分类。但是,我无法从sklearn导入svm模块。我已经安装了sklearn。我得到的错误如下:
>>> from sklearn import svm
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from sklearn import svm
File "C:\Python27\lib\site-packages\sklearn\svm\__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
File "C:\Python27\lib\site-packages\sklearn\svm\classes.py", line 1, in <module>
from .base import BaseLibLinear, BaseSVC, BaseLibSVM
File "C:\Python27\lib\site-packages\sklearn\svm\base.py", line 8, in <module>
from . import libsvm, liblinear
File "numpy.pxd", line 155, in init sklearn.svm.libsvm (sklearn\svm\libsvm.c:9096)
ValueError: numpy.dtype has the wrong size, try recompiling
任何建议将不胜感激。谢谢!
答案 0 :(得分:1)
正如错误消息似乎暗示,我会尝试重新安装scikit learn。如果这对你不起作用,你可能还需要重新安装numpy / scipy。
您可以使用此pip命令将scikit-learn升级到最新版本。
pip install -U scikit-learn