使用scikit函数时,我得到以下内容。我安装了scikit,numpy,scipy模块,我使用的是Ubuntu 14.04。
Ubuntu 14.04,scikit-learn == 0.17,scipy == 0.13.3,numpy == 1.10.4
代码:
import numpy as np
X = np.random.randint(5, size=(6, 100))
y = np.array([1, 2, 3, 4, 5, 6])
from sklearn.naive_bayes import MultinomialNB
clf = MultinomialNB()
clf.fit(X, y)
MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True)
print(clf.predict(X[2:3]))
错误:
Traceback (most recent call last):
File "scrap.py", line 20, in <module>
from sklearn.naive_bayes import MultinomialNB
File "/usr/local/lib/python2.7/dist-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/usr/local/lib/python2.7/dist-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 16, in <module>
from ..utils.fixes import signature
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/fixes.py", line 322, in <module>
from ._scipy_sparse_lsqr_backport import lsqr as sparse_lsqr
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/_scipy_sparse_lsqr_backport.py", line 58, in <module>
from scipy.sparse.linalg.interface import aslinearoperator
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/__init__.py", line 108, in <module>
from .isolve import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py", line 11, in <module>
from scipy.lib.decorator import decorator
ImportError: No module named decorator
如何解决这个问题?