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.