AI::MaxEntropy::Model - Perl extension for using Maximum Entropy Models


AI-MaxEntropy documentation  | view source Contained in the AI-MaxEntropy distribution.

Index


NAME

Top

AI::MaxEntropy::Model - Perl extension for using Maximum Entropy Models

SYNOPSIS

Top

  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');

DESCRIPTION

Top

This module manipulates models learnt by AI::MaxEntropy. For details about Maximum Entropy learner, please refer to AI::MaxEntropy.

FUNCTIONS

Top

new

Create a new model object from a model file.

  my $model = AI::MaxEntropy::Model->new('model_file');

predict

Get the most possible label for a unlabeled sample

  ...

  $y = $model->predict(['round', 'red']);

score

Get scores for every possible label for a unlabeled sample

  ...

  $s = $model->score(['round', 'red'] => 'apple');

save

Dumps the model to a file.

  ...

  $model->save('model_file');

load

Loads the model from a file.

  ...

  $model->load('model_file');

all_x

Returns a list of all x.

all_labels

Returns a list of all y (labels).

SEE ALSO

Top

AI::MaxEntropy

AUTHOR

Top

Laye Suen, <laye@cpan.org>

COPYRIGHT AND LICENSE

Top

REFERENCE

Top

A. L. Berge, V. J. Della Pietra, S. A. Della Pietra. A Maximum Entropy Approach to Natural Language Processing, Computational Linguistics, 1996.
S. F. Chen, R. Rosenfeld. A Gaussian Prior for Smoothing Maximum Entropy Models, February 1999 CMU-CS-99-108.

AI-MaxEntropy documentation  | view source Contained in the AI-MaxEntropy distribution.