Error pickling NaiveBayesClassifier
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 |
From: Toddy Mladenov <todd...@gmail.com>
Date: Wed, 7 Nov 2012 13:48:10 -0800
Local: Wed, Nov 7 2012 4:48 pm
Subject: Error pickling NaiveBayesClassifier
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/pic kle.py",
line 1370, in dump*
* Pickler(file, protocol).dump(obj)*
* File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pic kle.py",
line 203, in __init__*
* self.write = file.write*
*AttributeError: 'NaiveBayesClassifier' object has no attribute 'write'*
Any ideas how to save it?
Thanks!
Toddy
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Michael Deeringer <mdeerin...@gmail.com>
Date: Wed, 7 Nov 2012 16:50:31 -0500
Local: Wed, Nov 7 2012 4:50 pm
Subject: Re: [nltk-users] Error pickling NaiveBayesClassifier
I believe you want
pickle.dump(classifier, output, pickle.HIGHEST_PROTOCOL)
On Wed, Nov 7, 2012 at 4:48 PM, Toddy Mladenov <todd ...@gmail.com> wrote:
> 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/pic kle.py",
> line 1370, in dump*
> * Pickler(file, protocol).dump(obj)*
> * File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pic kle.py",
> line 203, in __init__*
> * self.write = file.write*
> *AttributeError: 'NaiveBayesClassifier' object has no attribute 'write'*
> Any ideas how to save it?
> Thanks!
> Toddy
> --
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Toddy Mladenov <todd...@gmail.com>
Date: Wed, 7 Nov 2012 14:02:48 -0800
Local: Wed, Nov 7 2012 5:02 pm
Subject: Re: [nltk-users] Error pickling NaiveBayesClassifier
wow! copy-and-paste programming can send me to jail :)
Thanks!
Toddy
On Wed, Nov 7, 2012 at 1:50 PM, Michael Deeringer <mdeerin...@gmail.com>wrote:
> I believe you want
> pickle.dump(classifier, output, pickle.HIGHEST_PROTOCOL)
> On Wed, Nov 7, 2012 at 4:48 PM, Toddy Mladenov <todd...@gmail.com> wrote:
>> 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/pic kle.py",
>> line 1370, in dump*
>> * Pickler(file, protocol).dump(obj)*
>> * File
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pic kle.py",
>> line 203, in __init__*
>> * self.write = file.write*
>> *AttributeError: 'NaiveBayesClassifier' object has no attribute 'write'*
>> Any ideas how to save it?
>> Thanks!
>> Toddy
>> --
> --
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Toddy Mladenov <todd...@gmail.com>
Date: Wed, 7 Nov 2012 14:13:53 -0800
Local: Wed, Nov 7 2012 5:13 pm
Subject: Re: [nltk-users] Error pickling NaiveBayesClassifier
As a follow up on this. Is this still an issue?
https://groups.google.com/forum/?fromgroups=#!topic/nltk-users/vijtEv...
I am having the same error when I load the pickle back. Changing to 1
solved the problem though so I am fine - just curious.
Toddy
On Wed, Nov 7, 2012 at 2:02 PM, Toddy Mladenov <todd ...@gmail.com> wrote:
> wow! copy-and-paste programming can send me to jail :)
> Thanks!
> Toddy
> On Wed, Nov 7, 2012 at 1:50 PM, Michael Deeringer <mdeerin...@gmail.com>wrote:
>> I believe you want
>> pickle.dump(classifier, output, pickle.HIGHEST_PROTOCOL)
>> On Wed, Nov 7, 2012 at 4:48 PM, Toddy Mladenov <todd...@gmail.com> wrote:
>>> 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/pic kle.py",
>>> line 1370, in dump*
>>> * Pickler(file, protocol).dump(obj)*
>>> * File
>>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pic kle.py",
>>> line 203, in __init__*
>>> * self.write = file.write*
>>> *AttributeError: 'NaiveBayesClassifier' object has no attribute 'write'*
>>> Any ideas how to save it?
>>> Thanks!
>>> Toddy
>>> --
>> --
You must Sign in before you can post messages.
You do not have the permission required to post.
|
|
|