Reputation: 309
Whenever I try to call a new classifier I get the same error...
Here's my code:
from nltk.classify.scikitlearn import SklearnClassifier
from sklearn.naive_bayes import BernoulliNB
BernoulliNB_classifier = SklearnClassifier(BernoulliNB())
Here's the error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python34\lib\site-packages\nltk\classify\scikitlearn.py", line 69, in __init__
self._encoder = LabelEncoder()
NameError: name 'LabelEncoder' is not defined
When I look at the documentation that's exactly how it should be called (see http://www.nltk.org/api/nltk.classify.html)
Plus, it works on Python 2.7.
NB: I tried with the multinomial naive bayes, the support vector machines and many other algos, it returns the same error.
Upvotes: 6
Views: 9170