Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a simple recommendation system?

How to build a simple recommendation system? I have seen some algorithms but it is so difficult to implement I wish their is practical description to implement the most simple algorithm?

i have these three tables

        Users
  userid      username
   1            aaa
   2            bbb

and

        products
  productid        productname
     1                laptop
     2                mobile phone
     3                car

and

      users_products
  userid        productid
    1                1
    1                3
    3                2
    2                3

so I want to be able recommend items for each of the users depending on the items they purchased and other users' items

I knew it should something like calculating the similarites between users and then see their prosucts but how can be this done and stored in a database because this will require a table with something like this

      1    2   3   4   5   6 << users' ids
 1)   1   .4  .2  .3  .8  .4
 2)  .3    1  .5  .7  .3  .9
 3)  .4   .4   1  .8  .2  .3
 4)  .6   .6  .6   1  .4  .2
 5)  .8   .7  .4  .2   1  .3
 6)   1   .4  .6  .7  .9   1
 ^
 ^
users'
 ids

so how can similarty beween users calculated? and how could this complex data stored in ad database? (it requires a table with column for every user)? thanks

like image 896
ahmed Avatar asked Jan 31 '09 17:01

ahmed


2 Answers

How you want to actually store the recommendations is as a question completely unrelated to how one would actually implement a recommendation engine. I leave that to your database architecture. On to the recommending.

You said "simple", so a Pearson correlation coefficient might be the thing you need to read up on.

Calculating such a thing is dead simple. Concept, example code.

like image 74
JosefAssad Avatar answered Sep 22 '22 22:09

JosefAssad


Maybe reading "Programming Collective Intelligence" will help you.

like image 38
duffymo Avatar answered Sep 24 '22 22:09

duffymo