搜索内容

有一个问题?

如果您有任何疑问,可以在下面询问或输入您要寻找的!

引入朴素贝叶斯模型时,出现报错,该怎么解决?

技术聚客 未结 1 1457
from sklearn.naive_bayes import CategoricalNB

报错信息:

--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-7-99f84f9c107a> in <module>() 1 #建立模型,引入模型 ----> 2 from sklearn.naive_bayes import CategoricalNB ~\AppData\Roaming\Python\Python36\site-packages\sklearn\__init__.py in <module>() 80 from . import _distributor_init # noqa: F401 81 from . import __check_build # noqa: F401 ---> 82 from .base import clone 83 from .utils._show_versions import show_versions 84 ~\AppData\Roaming\Python\Python36\site-packages\sklearn\base.py in <module>() 15 from . import __version__ 16 from ._config import get_config ---> 17 from .utils import _IS_32BIT 18 from .utils._tags import ( 19 _DEFAULT_TAGS, ~\AppData\Roaming\Python\Python36\site-packages\sklearn\utils\__init__.py in <module>() 21 22 from .murmurhash import murmurhash3_32 ---> 23 from .class_weight import compute_class_weight, compute_sample_weight 24 from . import _joblib 25 from ..exceptions import DataConversionWarning ~\AppData\Roaming\Python\Python36\site-packages\sklearn\utils\class_weight.py in <module>() 5 import numpy as np 6 ----> 7 from .validation import _deprecate_positional_args 8 9 ~\AppData\Roaming\Python\Python36\site-packages\sklearn\utils\validation.py in <module>() 24 from contextlib import suppress 25 ---> 26 from .fixes import _object_dtype_isnan, parse_version 27 from .. import get_config as _get_config 28 from ..exceptions import PositiveSpectrumWarning ~\AppData\Roaming\Python\Python36\site-packages\sklearn\utils\fixes.py in <module>() 18 import scipy.sparse as sp 19 import scipy ---> 20 import scipy.stats 21 from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa 22 from numpy.ma import MaskedArray as _MaskedArray # TODO: remove in 1.0 ~\anaconda3\envs\imooc\lib\site-packages\scipy\stats\__init__.py in <module>() 346 from __future__ import division, print_function, absolute_import 347 --> 348 from .stats import * 349 from .distributions import * 350 from .morestats import * ~\anaconda3\envs\imooc\lib\site-packages\scipy\stats\stats.py in <module>() 175 import scipy.special as special 176 import scipy.linalg as linalg --> 177 from . import distributions 178 from . import mstats_basic 179 from ._distn_infrastructure import _lazywhere ~\anaconda3\envs\imooc\lib\site-packages\scipy\stats\distributions.py in <module>() 11 rv_frozen) 12 ---> 13 from . import _continuous_distns 14 from . import _discrete_distns 15 ~\anaconda3\envs\imooc\lib\site-packages\scipy\stats\_continuous_distns.py in <module>() 13 from scipy import integrate 14 import scipy.special as sc ---> 15 from scipy._lib._numpy_compat import broadcast_to 16 17 from . import _stats ~\anaconda3\envs\imooc\lib\site-packages\scipy\_lib\_numpy_compat.py in <module>() 8 9 import numpy as np ---> 10 from numpy.testing.nosetester import import_nose 11 12 from scipy._lib._version import NumpyVersion ModuleNotFoundError: No module named 'numpy.testing.nosetester'

自己网上查过解决方案,好像说需要升级pip,numpy,sklearn的版本,但升级后还是报错。

附上各环境包版本号

# Name Version Build Channel argon2-cffi 20.1.0 pypi_0 pypi blas 1.0 mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free bleach 1.5.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free certifi 2016.2.28 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free cffi 1.14.5 pypi_0 pypi colorama 0.3.9 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free cycler 0.10.0 pypi_0 pypi decorator 4.1.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free entrypoints 0.2.3 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free html5lib 0.9999999 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free ipykernel 4.6.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free ipython 6.1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free ipython_genutils 0.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free jedi 0.10.2 py36_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free jinja2 2.9.6 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free joblib 1.0.1 pypi_0 pypi jsonschema 2.6.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free jupyter-client 6.1.11 pypi_0 pypi jupyter-core 4.7.1 pypi_0 pypi jupyter_client 5.1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free jupyter_core 4.3.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free jupyterthemes 0.20.0 pypi_0 pypi kiwisolver 1.3.1 pypi_0 pypi lesscpy 0.14.0 pypi_0 pypi markupsafe 1.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free matplotlib 3.3.4 pypi_0 pypi mistune 0.7.4 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free mkl 2017.0.3 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free mpmath 1.2.1 pypi_0 pypi nbconvert 5.2.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free nbformat 4.4.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free notebook 6.2.0 pypi_0 pypi numpy 1.19.5 pypi_0 pypi pandas 0.20.3 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pandocfilters 1.4.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free path.py 10.3.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pickleshare 0.7.4 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pillow 8.1.0 pypi_0 pypi pip 21.0.1 pypi_0 pypi ply 3.11 pypi_0 pypi prometheus-client 0.9.0 pypi_0 pypi prompt_toolkit 1.0.15 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pycparser 2.20 pypi_0 pypi pygments 2.2.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pyparsing 2.4.7 pypi_0 pypi python 3.6.2 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free python-dateutil 2.6.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pytz 2017.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free pywin32 300 pypi_0 pypi pywinpty 0.5.7 pypi_0 pypi pyzmq 22.0.3 pypi_0 pypi scikit-learn 0.19.0 np113py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free scipy 1.5.4 pypi_0 pypi send2trash 1.5.0 pypi_0 pypi setuptools 36.4.0 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free simplegeneric 0.8.1 py36_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free six 1.10.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free sklearn 0.0 pypi_0 pypi sympy 1.7.1 pypi_0 pypi terminado 0.9.2 pypi_0 pypi testpath 0.3.1 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free threadpoolctl 2.1.0 pypi_0 pypi tornado 6.1 pypi_0 pypi traitlets 4.3.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free vc 14 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free vs2015_runtime 14.0.25420 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free wcwidth 0.1.7 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free wheel 0.29.0 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free wincertstore 0.2 py36_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

 

1条回答
提交回复