The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Redis::Bayes - stochastic Baysian classification on Redis

SYNOPSIS

EXAMPLES:

  my $rb = Redis::Bayes->new;
  $rb->train('apple_computer',q{I'm going to pick up a new retina display MacBook!});
  $rb->train('apple_fruit',q{That thing is rotten at the seeds.});
  my $result = $rb->classify("retina display");

DESCRIPTION

This module is an implementation of naive Bayes on Redis.

METHODS

new

  my $rb = Redis::Bayes->new; # defaults to Redis->new(reconnect => 2, every => 100);
  # or
  my $rb = Redis::Bayes->new(
    prefix => 'yourownprefixhere:',
    stopwords => {blah => 1, whatever => 1},
    redis => $redis,
  );
prefix

Redis database prefix. The default is 'bayes:'.

stopwords

The set of words to filter when training. The default uses Lingua::StopWords.

redis

Defaults to Redis->new(reconnect => 2, every => 100). Otherwise, use delegation here.

train

  $rb->train('apple','sauce');

Train using <label, document>.

untrain

  $rb->untrain('apple','sauce');

Untrains <label, document>.

flush

  $rb->flush;

Flushes all trained data.

classify

  $rb->classify(q{there's a computer on the desk});

Returns the label with the highest confidence metric for the given document.

SEE ALSO

Redis

ACKNOWLEDGEMENTS

This module is ported loosely from other such packages in node and python, i.e. https://github.com/harthur/classifier and https://github.com/jart/redisbayes and https://github.com/didip/bayes_on_redis, with some modifications.

AUTHOR

Andrew Shapiro, <trski@cpan.org>

BUGS

Please report any bugs or feature requests to bug-redis-bayes at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Redis-Bayes. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE AND COPYRIGHT

Copyright 2013 Andrew Shapiro.

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.