NAME
AI::NaiveBayes::Learner - Build AI::NaiveBayes classifier from a set of training examples.
VERSION
version 0.01
SYNOPSIS
my $learner = AI::NaiveBayes::Learner->new(features_kept => 0.5);
$learner->add_example(
{
attributes => { sheep => 1, very => 1, valuable => 1, farming => 1 },
labels => ['farming']
},
);
my $classifier = $learner->classifier;
DESCRIPTION
This is a trainer of AI::NaiveBayes classifiers. It saves information passed by the add_example method from training data into internal structures and then constructs a classifier when the classifier method is called.
ATTRIBUTES
features_kept-
Indicates how many features should remain after calculating probabilities. By default all of them will be kept. For
features_kept> 1,features_keptof features will be preserved. For values lower than 1, a specified fraction of features will be kept (e.g. top 20% of features forfeatures_kept= 0.2).The rest of the attributes is for class' internal usage, and thus not documented.
classifier_class-
The class of the classifier to be created. By default it is
AI::NaiveBayes
METHODS
add_example( HASHREF )-
Saves the information from a training example into internal data structures. The parameter should be of the form of { feature1 => weight1, feature2 => weight2, ... }
classifier()-
Creates an AI::NaiveBayes classifier based on the data accumulated before.
UTILITY SUBS
add_hash
BASED ON
Much of the code and description is from Algorithm::NaiveBayes.
AUTHORS
Zbigniew Lukasiak <zlukasiak@opera.com>
Tadeusz Sośnierz <tsosnierz@opera.com>
Ken Williams <ken@mathforum.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Opera Software ASA.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 169:
'=item' outside of any '=over'
- Around line 171:
You forgot a '=back' before '=head1'
- Around line 185:
Non-ASCII character seen before =encoding in 'Sośnierz'. Assuming UTF-8