Statistics::Suggest - Perl binding for collaborative filtering library SUGGEST.
Download SUGGEST from http://glaros.dtc.umn.edu/gkhome/suggest/download.
libsuggest.a which matches your environment and place it under your library path (or specify its path with LIBS option as shown below).
perl Makefile.PL [LIBS='-L/where/to/find/libsuggest.a -lsuggest'] make make test make install
Tested with suggest-1.0-linux.
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);
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.
my $s = new Statistics::Suggest( # parameters for Init function (see SUGGEST's manual p.5) RType => 2, NNbr => 40, Alpha => 0.3, );
Loads user-item transactions that will be used to make recommendations.
$s->load_trans([ # [user_id, item_id], ... [1, 1], [1, 2], [1, 4],... ]);
Alpha parameter can be set automatically by calling
estimate_alpha method after
load_trans, before calling
Initializes the SUGGEST engine. Should be called after all transactions are loaded via
Returns top-n recommendations for the given item set. Should be called after
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);
None by default.
Ikuhiro IHARA <email@example.com>
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.