Algorithm::Bayesian - Bayesian Spam Filtering Algorithm
tie %storage, 'Tie:Foo', ...;
my $b = Algorithm::Bayesian->new(\%storage);
$b->spam('spamword1', 'spamword2', ...);
$b->ham('hamword1', 'hamword2', ...);
my $pr = $b->test('word1', 'word2', ...);
Algorithm::Bayesian provide an easy way to handle Bayesian spam filtering algorithm.
my $b = Algorithm::Bayesian->new(\%hash);
Constructor. Simple hash would be fine. You can use Tie::DBI to store data to RDBM, or other key-value storage.
my $num = $b->getHam($word);
Get $word count in Ham.
my $num = $b->getSpam($word);
Get $word count in Spam.
Train @words as Ham.
Train @words as Spam.
my $pr = $b->test(@words);
Calculate the spam probability of @words. The range of $pr will be in 0 to 1.
my $pr = $b->testWord($word);
Calculate the spam probability of $word.
The range of $pr will be in 0 to 1. For non-existence word, it will be 0.5.
Gea-Suan Lin, <gslin at gslin.org>
<gslin at gslin.org>
Copyright 2010 Gea-Suan Lin.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Algorithm::Bayesian, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.