Answer the question
In order to leave comments, you need to log in
Error when working with the naiveBayesClassifier library, how to solve the problem ImportError: No module named 'ExceptionNotSeen?
Hello everyone, now I'm trying to figure out the naiveBayesClassifier library and trying it on an example from Github here .
So here is the actual code:
from naiveBayesClassifier import tokenizer
from naiveBayesClassifier.trainer import Trainer
from naiveBayesClassifier.classifier import Classifier
newsTrainer = Trainer(tokenizer)
newsSet =[
{'text': 'not to eat too much is not enough to lose weight', 'category': 'health'},
{'text': 'Russia try to invade Ukraine', 'category': 'politics'},
{'text': 'do not neglect exercise', 'category': 'health'},
{'text': 'Syria is the main issue, Obama says', 'category': 'politics'},
{'text': 'eat to lose weight', 'category': 'health'},
{'text': 'you should not eat much', 'category': 'health'}
]
for news in newsSet:
newsTrainer.train(news['text'], news['category'])
newsClassifier = Classifier(newsTrainer.data, tokenizer)
classification = newsClassifier.classify("Obama is")
print(classification)
Traceback (most recent call last):
File "/Users/YouTube/PycharmProjects/neturalnetw/naive.py", line 7, in
from naiveBayesClassifier.trainer import Trainer
File "/Library/Frameworks/Python.framework/Versions/3.5/lib /python3.5/site-packages/naiveBayesClassifier/trainer.py", line 1, in
from naiveBayesClassifier.trainedData import TrainedData
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages /naiveBayesClassifier/trainedData.py", line 1, in
from ExceptionNotSeen import NotSeen
ImportError: No module named 'ExceptionNotSeen'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question