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.
try restarting the kernel, worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With