Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Error pickling NaiveBayesClassifier
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Toddy Mladenov  
View profile  
 More options Nov 7 2012, 4:48 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Deeringer  
View profile  
 More options Nov 7 2012, 4:51 pm
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)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Toddy Mladenov  
View profile  
 More options Nov 7 2012, 5:02 pm
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Toddy Mladenov  
View profile  
 More options Nov 7 2012, 5:13 pm
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »