Grokbase Groups Perl ai August 2004
FAQ
Hi PerlDiscuss - Perl Newsgroups and mailing lists,

It's not really inheritance that's lost, it's the actual module code.
You should be able to solve this by just adding a 'use
Algorithm::NaiveBayes::Model::Frequency;' to the second script.

Or if you don't want to hard-code that, you can do:

$nb = AI::Categorizer::Learner::NaiveBayes->restore_state('filename');
eval( 'use ' . ref($nb) );

To solve this correctly, I think I'd have to add this to the
restore_state() method in the NaiveBayes learner class.

-Ken


On Aug 31, 2004, at 6:12 AM, PerlDiscuss - Perl Newsgroups and mailing
lists wrote:
Hi folks,

I'm trying to implement AI:Categorizer. Everything works fine
until I try to save and restore the state of the learner.

From the synopsis...

my $nb = new
AI::Categorizer::Learner::NaiveBayes(...parameters...);
$nb->train(knowledge_set => $k);
$nb->save_state ('filename');

--- later ----

$nb =
AI::Categorizer::Learner::NaiveBayes->restore_state('filename');
my $c = new AI::Categorizer::Collection::Files( path => ... );
while (my $document = $c->next) {
my $hypothesis = $nb->categorize($document);
print "Best assigned category: ",
$hypothesis->best_category, "\n";
print "All assigned categories: ", join(', ',
$hypothesis->categories), "\n";

However when the line
my $hypothesis = $nb->categorize($document);
is executed I get the following error.

Can't locate object method "predict" via package
"Algorithm::NaiveBayes::Model::Frequency"
at /usr/lib/perl5/site_perl/5.8.3/AI/Categorizer/Learner/NaiveBayes.pm
line 28.

It seems like inheritance is lost between save and restore
states. Any ideas?

Thanks in advance.

PS: CC to email highly appreciated.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 7 | next ›
Discussion Overview
groupai @
categoriesperl
postedAug 31, '04 at 11:12a
activeDec 9, '06 at 12:12a
posts7
users6
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase