I am trying to save my trained Naive Bayes classifier in python. I've followed previous, similar questions to no avail. I'm kind of new to Python and don't really understand what is wrong, I've created and trained my classifier as per the NLTK book. How can I save this model to work on it later?
This is the error I've been stuck with:
picklingError: Can't pickle <class 'generator'>: attribute lookup generator on builtin failed
Currently I have:
classifier = nltk.NaiveBayesClassifier.train(train_set)
saveClassifier(classifier)
def saveClassifier(classifier):
with open('cp_model.pkl', 'w') as f:
dump(classifier, f)
Any help at all would be appreciated, I've literally been trying to fix this for hours.
Thanks.