AI::NaiveBayes::Learner - Build AI::NaiveBayes classifier from a set of training examples.
version 0.03
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;
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.
add_example
classifier
features_kept
Indicates how many features should remain after calculating probabilities. By default all of them will be kept. For features_kept > 1, features_kept of features will be preserved. For values lower than 1, a specified fraction of features will be kept (e.g. top 20% of features for features_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
AI::NaiveBayes
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.
add_hash
Much of the code and description is from Algorithm::NaiveBayes.
Zbigniew Lukasiak <zlukasiak@opera.com>
Tadeusz Sośnierz <tsosnierz@opera.com>
Ken Williams <ken@mathforum.org>
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.
To install AI::NaiveBayes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::NaiveBayes
CPAN shell
perl -MCPAN -e shell install AI::NaiveBayes
For more information on module installation, please visit the detailed CPAN module installation guide.