没有名为 NaiveBayes 的模块
No module named 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 这样的模块。
---------------------------------------------------------------------------
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。
代码似乎不是来自 scikit-learn Naive Bayes algorithms,无论如何,它没有 Pool
属性或方法。
您似乎正在尝试使用 another NaiveBayes library,在这种情况下,您的导入应该是
from NaiveBayes.Pool import Pool
如图example那里。但是该消息暗示您尚未安装它;从 shell
尝试
git clone https://github.com/yveskaufmann/Naive-Bayes
在您的当前目录中(另请参阅 documentation 用于克隆 Github 存储库)。
我们正在实施的代码是
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 这样的模块。
---------------------------------------------------------------------------
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。
代码似乎不是来自 scikit-learn Naive Bayes algorithms,无论如何,它没有 Pool
属性或方法。
您似乎正在尝试使用 another NaiveBayes library,在这种情况下,您的导入应该是
from NaiveBayes.Pool import Pool
如图example那里。但是该消息暗示您尚未安装它;从 shell
尝试git clone https://github.com/yveskaufmann/Naive-Bayes
在您的当前目录中(另请参阅 documentation 用于克隆 Github 存储库)。