没有名为NaiveBayes的模块 [英] No module named NaiveBayes

查看:102
本文介绍了没有名为NaiveBayes的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在实现的代码是

from NaiveBayes import  Pool
import os

DClasses = ["python",  "java",  "hadoop",  "django",  "datascience",  "php"]

base = "learn/"
p = Pool()
for i in DClasses:
    p.learn(base + i, i)



base = "test/"
for i in DClasses:
    dir = os.listdir(base + i)
    for file in dir:
        res = p.Probability(base + i + "/" + file)
        print(i + ": " + file + ": " + str(res))

但是我们遇到了错误,就像没有找到像naivebayes这样的模块.

but we are getting error like no module found like naivebayes.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-21-30788f518a4c> in <module>()
----> 1 from NaiveBayes import  Pool
      2 import os
      3 
      4 DClasses = ["python",  "java",  "hadoop",  "django",  "datascience",  "php"]
      5 

ModuleNotFoundError: No module named 'NaiveBayes'

帮助消除此错误.谢谢.

Help to eradicate this error.Thanks.

推荐答案

该代码似乎不是来自

The code does not seem to be from the scikit-learn Naive Bayes algorithms, which, in any case, do not have a Pool attribute or method.

似乎您正在尝试使用另一个NaiveBayes库,在这种情况下,您的导入应是

It seems you are trying to use another NaiveBayes library, in which case your import should be

from NaiveBayes.Pool import Pool

示例所示.但是该消息表明您尚未安装它.从外壳尝试

as shown in the example there. But the message implies that you have not installed it; try from the shell

git clone https://github.com/yveskaufmann/Naive-Bayes

在当前目录中(另请参阅文档来克隆Github回购).

in your current directory (see also the documentation for cloning Github repos).

这篇关于没有名为NaiveBayes的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆