Sklearn error while trying to call new classifier - Python 3.4

Whenever I try to call a new classifier, I get the same error ...

Here is 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, exactly how it should be called (see http://www.nltk.org/api/nltk.classify.html )

In addition, it runs on Python 2.7.

NB: I tried to use multi-million dollar naive bikes, support vector machines and many other algorithms, it returns the same error.

+4
source share

Source: https://habr.com/ru/post/1650426/


All Articles