AI::MaxEntropy::Model - Perl extension for using Maximum Entropy Models
use AI::MaxEntropy::Model; # learn a model by AI::MaxEntropy require AI::MaxEntropy; my $me = AI::MaxEntropy->new; $me->see(['round', 'smooth', 'red'] => 'apple' => 2); $me->see(['long', 'smooth', 'yellow'] => 'banana' => 3); $me->see(['round', 'rough'] => 'orange' => 2); my $model = $me->learn; # make prediction on unseen data # ask what a red round thing is most likely to be my $y = $model->predict(['round', 'red']); # the answer apple is expected # print out scores of all possible labels for ($model->all_labels) { my $s = $model->score(['round', 'red'] => $_); print "$_: $s\n"; } # save the model to file $model->save('model_file'); # load the model from file $model->load('model_file');
This module manipulates models learnt by AI::MaxEntropy. For details about Maximum Entropy learner, please refer to AI::MaxEntropy.
Create a new model object from a model file.
my $model = AI::MaxEntropy::Model->new('model_file');
Get the most possible label for a unlabeled sample
... $y = $model->predict(['round', 'red']);
Get scores for every possible label for a unlabeled sample
... $s = $model->score(['round', 'red'] => 'apple');
Dumps the model to a file.
... $model->save('model_file');
Loads the model from a file.
... $model->load('model_file');
Returns a list of all x.
Returns a list of all y (labels).
AI::MaxEntropy
Laye Suen, <laye@cpan.org>
The MIT License
Copyright (C) 2008, Laye Suen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install AI::MaxEntropy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::MaxEntropy
CPAN shell
perl -MCPAN -e shell install AI::MaxEntropy
For more information on module installation, please visit the detailed CPAN module installation guide.