Subject: | Can't take log of 0 |
Example script dies with
Can't take log of 0 at c:/perl/site/lib/Statistics/Contingency.pm line 183.
AI::Categorizer 0.09
Statistics::Contingency 0.06
--
Alexandr Ciornii, http://chorny.net
Subject: | categ-log.pl |
use strict;
use warnings;
use AI::Categorizer;
my %data=(
'd1'=>{
categories => ['a'],
content => 'excluding',
}
);
my %data1=(
'd2'=>{
content => 'including',
}
);
use AI::Categorizer::Collection::InMemory;
my $training = AI::Categorizer::Collection::InMemory->new(data => \%data);
my $test = AI::Categorizer::Collection::InMemory->new( data => \%data1 );
use AI::Categorizer::KnowledgeSet;
use AI::Categorizer::Learner::NaiveBayes;
#my $c = new AI::Categorizer(knowledge_set=>$c1);
print "Loading training set\n";
my $k = AI::Categorizer::KnowledgeSet->new( verbose => 1 );
$k->load( collection => $training );
print "Training categorizer\n";
my $l = AI::Categorizer::Learner::NaiveBayes->new( verbose => 1 );
$l->train( knowledge_set => $k );
print "Categorizing test set\n";
my $experiment = $l->categorize_collection( collection => $test );
print $experiment->stats_table;