Vogoo tutorial
PHP Tutorial
square  Tutorial
square  Installation
square  Manual
Tutorial
This tutorial is a quick guide to the main functions of Vogoo PHP Lib and Vogo PHP Pro.
We've also added a copy of the Installation process and of the Library Manual that you will find in the 'docs' directory of Vogoo PHP.

Entering ratings
Once you've installed Vogoo PHP you can start using it by including the following directive in your scripts :

   include('vogoo/vogoo.php');

The first step will be to enter the ratings users gave to the items on your website.
For instance, if user 1 has given a rating of 3/5 to item 3, you will enter this rating using the following command :

   $vogoo->set_rating(1, 3, 0.8);

The rating needs to be converted to a number in the range [0..1]: 4/5 = 0.8
This is to allow Vogoo PHP to work in the same way on all websites without having to know if items are rated out of 5, 10 or 100.

Let's add a few other ratings for our example : user 1 rated item 2 5/5; user 2 rated item 3 4.5/5

   $vogoo->set_rating(1, 2, 1.0);
   $vogoo->set_rating(2, 3, 0.9);

The $vogoo->set_rating can also be used to update an existing rating.

To access the ratings already entered in the system, you can use $vogoo->get_rating, $vogoo->member_ratings or $vogoo->product_ratings functions.

Item-based Collaborative Filtering
This section will show you how to use the first item-based engine included in Vogoo PHP.
Before getting any recommendation you first need to compute links (correlations) between items.
To do so, open the following webpage in your internet browser :

   http://yourwebsite/vogoo/cronlinks.php

No output is shown as this command is expected to be run in the background (cf. Library Manual). However, you can see that the command has completed when the webpage loading icon has stopped spinnig in your browser.

Once the links between items have been computed, you can use the CF engine by creating a new script including items.php (you still need to incude vogoo.php as it is the base module) :

   include('vogoo/vogoo.php');
   include('vogoo/items.php');

Then simply call the following function to get recommendations for user 2 :

   $ret = $vogoo_items->member_get_recommended_items(2);

Each row of the $ret array contains an item ID of a product that can be recommended to user 2. The items are ordered from the most recommended to the least recommended.

Based on the 3 ratings entered earlier, we can see that user 1 has liked both items 2 and 3.
User 2 likes item 2 but hasn't rated item 3.

Hence, $ret will contain 1 row with item 3 which means that this item can be recommended to user 2.

User-based Collaborative Filtering
User-based CF looks for similarities between users instead of looking for similarities between products. To use, User-based CF in Vogoo PHP, create a new script including users.php :

   include('vogoo/vogoo.php');
   include('vogoo/users.php');

To get the users whose tastes are closest to user 2, call:

   $vogoo_users->member_k_similarities(2,20,$sims);
       where 20 is the maximum number of users returned by the function

This function returns its result in the $sims variable as an array where each element contains a user ID, and the percentage of similarity between this user and user 2.
For instance, the following will return 1 in our example since user 1 is the closest member to member 2 :

   $sims[0]['member_id'];

and his similarity to user 2 (0.95 which means 95%) is obtained in :

   $sims[0]['sim']

Once you have the similarities for user 2, you can get items recommendations by calling :

   $vogoo_users->member_k_similarities(2,10,$sims);
       where 10 is the maximum number of recommendations returned by the function

This function will return an array where each element contains:
  • the user ID on which the recommendation is based to recommend the item to user 2
  • the similarity between this user and user 2
  • the ID of the recommended item
  • the rating given by the recommending user to this item
  • the time when this rating was given
In our example, this array would have only one row with the following values:
  • the user ID on which the recommendation is based to recommend the item : 1
  • the similarity between this user and user 2 : 0.95
  • the ID of the recommended item : 2
  • the rating given by the recommending user to this item : 1.0
  • the time when this rating was given
© 2005-2007 Stéphane DROUX