Hello Everybody,
My understanding was that the simplest way to save trained classifier is to pickle it to a file however when I do the following:
>>> classifier = nltk.NaiveBayesClassifier.train(train_set)
>>> output = open('/Users/toddysm/Development/temp/classifier.pickle', 'wb')
>>> pickle.dump(mydic, classifier, pickle.HIGHEST_PROTOCOL)
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1370, in dump
Pickler(file, protocol).dump(obj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 203, in __init__
self.write = file.write
AttributeError: 'NaiveBayesClassifier' object has no attribute 'write'
Any ideas how to save it?
Thanks!
Toddy