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

NAME

Statistics::Suggest - Perl binding for collaborative filtering library SUGGEST.

INSTALLATION

Download SUGGEST from http://glaros.dtc.umn.edu/gkhome/suggest/download.

Find libsuggest.a which matches your environment and place it under your library path (or specify its path with LIBS option as shown below).

Then do:

   perl Makefile.PL [LIBS='-L/where/to/find/libsuggest.a -lsuggest']
   make
   make test
   make install

Tested with suggest-1.0-linux.

SYNOPSIS

  use Statistics::Suggest;
  
  ## initialize SUGGEST with $data
  my $data = [
    # array of [$user_id, $item_id], ...
    [1, 1], [1, 2], [1, 4], [1, 5]
    [2, 1], [2, 2], [2, 4],
    [3, 3], [3, 4],
    [4, 3], [4, 4], [4, 5],
    ...
  ];
  
  my $s = new Statistics::Suggest(
    RType => 2,
    NNbr => 40,
    Alpha => 0.3,
  );
  $s->load_trans($data);
  $s->init;

  ## make top 10 recommendations for $selected_item_ids
  my $rcmds;
  my $selected_item_ids = [1, 2];
  $s->top_n($selected_item_ids, 10, \$rcmds)
  
  print "recommendations: " . join(',', @$rcmds);

DESCRIPTION

This is a perl binding for SUGGEST. Please refer to the SUGGEST's manual for details. Basically, this package contains all corresponding methods for functions described in the manual.

new

  my $s = new Statistics::Suggest(
    # parameters for Init function (see SUGGEST's manual p.5)
    RType => 2,
    NNbr => 40,
    Alpha => 0.3,
  );

load_trans

Loads user-item transactions that will be used to make recommendations.

  $s->load_trans([
    # [user_id, item_id], ...
    [1, 1], [1, 2], [1, 4],...
  ]);

estimate_alpha

Alpha parameter can be set automatically by calling estimate_alpha method after load_trans, before calling init.

  $s->estimate_alpha;

init

Initializes the SUGGEST engine. Should be called after all transactions are loaded via load_trans method.

  $s->init;

top_n

Returns top-n recommendations for the given item set. Should be called after init.

  my $rcmds;
  $s->top_n(
    [3, 4, 5, ... ], # array of item_ids in the user's basket
    10, # number of recommendations required
    \$rcmds, # reference of an array reference for storing recommendations
  );
  print join(',', @$rcmds);

EXPORT

None by default.

SEE ALSO

http://glaros.dtc.umn.edu/gkhome/suggest/overview

AUTHOR

Ikuhiro IHARA <tsukue@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Ikuhiro IHARA

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.