我们正在实现的代码是
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))但是我们得到了错误,就像找不到像奈维巴耶那样的模块。
---------------------------------------------------------------------------
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'帮助根除这种error.Thanks。
发布于 2018-08-29 13:54:51
代码似乎不是来自学习朴素贝叶斯算法,在任何情况下,它都没有Pool属性或方法。
似乎您正在尝试使用另一个NaiveBayes库,在这种情况下,您的导入应该是
from NaiveBayes.Pool import Pool如示例中所示。但是该消息意味着您尚未安装它;请从shell中尝试。
git clone https://github.com/yveskaufmann/Naive-Bayes在您的当前目录中(也请参阅文档中的克隆Github repos)。
https://stackoverflow.com/questions/52078969
复制相似问题