I'm using nltk
with a scikit-learn classifier and the interface is throwing an error I cannot explain.
Here is a minimum working example:
import nltk
import sklearn
from sklearn.naive_bayes import MultinomialNB
nltk.classify.scikitlearn.SklearnClassifier(MultinomialNB())
This throws the error
name 'LabelEncoder' is not defined
Importing LabelEncoder (as suggested here) does not work – and it would be strange if it did. Looking at the source code of nltk.classify.scikitlearn
, LabelEncoder
should be loaded internally.
It seems this is problem of my local installation rather than the nltk or sklearn package. I'm out of ideas, though. Does anyone have an idea what might be going wrong here?
Versions:
nltk.__version__ '3.5';
sklearn.__version__ '0.24.0';
sys.version
'3.9.1 (default, Jan 8 2021, 17:17:43) [Clang 12.0.0 (clang-1200.0.32.28)]