The code we are implementing is
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))
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.It seems you are trying to use another NaiveBayes library, in which case your import should be
as shown in the example there. But the message implies that you have not installed it; try from the shell
in your current directory (see also the documentation for cloning Github repos).