SerotoninChase
SerotoninChase

Reputation: 424

Recommendation System for a book store application

Hey I'm trying to learn some of the recommendation algorithms that's being used in websites like Amazon.com. So I have this simple java (spring hibernate postgres) book store application where in Book has the attributes title, category, tags, author. For simplicity there's no content inside the book. A book has to be identified by its title, category, author and tags. For each user logging into the application I should be able to recommend some books. Each user can view a book, add them to cart and buy it anytime. So in the database I'm storing how many times each user looked at a book, the books in his cart and the books the user has bought. At the moment there's no rating option but that can be added too.

So can someone tell me what are the algorithms I could use to demonstrate some recommendation of books for each user? I want to keep it really simple. Its not a project to sell but only to expand my knowledge on recommendation algorithms. So assume there are only about 30 books in total(5 categories and 6 books in each). It would be really helpful if someone could also tell me what should be the attributes I should be using to calculate similarities between two users and how to go about it with the algorithms recommended.

Thanks in advance. SerotoninChase.

Upvotes: 3

Views: 4148

Answers (4)

isomorphismes
isomorphismes

Reputation: 8403

You have a gigantic amount of freedom here. Make up a measure of similarity between two users and then make a monotonic function that takes similar users' ratings of books as input and returns scores for each book. The standard solution is to use matrix multiplication.

Upvotes: 1

Mac
Mac

Reputation: 14791

As a particular concrete example, one option is a "nearest K neighbours" algorithm.

To simplify things, imagine you only had ten books, and you were only tracking how many times each user viewed each book. Then, for each user, you might have an array int timesViewed[10], where the value of timesViewed[i] is the number of times the user has viewed book number i.

You can then compare the user to all of the other users using a correlation function, such as the Pearson correlation for example. Computing the correlation between the current user c and another user o gives a value between -1.0 and 1.0, where -1.0 means "this user c is the complete opposite of the other user o", and 1.0 means "this user c is the same as the other user o".

If you compute the corellation between c and every other user, you get a list of results of how similar the user's viewing pattern is to that of each other user. You then pick the K (e.g. 5, 10, 20) most similar results (hence the name of the algorithm), that is, the K users with the correlation scores closest to 1.0.

Now, you can do a weighted average of each of those user's timesViewed arrays. For example, we'll say averageTimesViewed[0] is the average of the timesViewed[0] for each of those K users, weighted by their correlation score. Then do the same for each other averageTimesViewed[i].

Now you have an array averageTimesViewed which contains, roughly speaking, the average number of times the K users with the most similar viewing patterns to c has viewed each book. Recommend the book which has the highest averageTimesViewed score, since this is the book the other users have shown most interest in.

It's usually worth also excluding books the user has already viewed from being recommended, but it is still important to keep those accounted for when computing similarity/correlation.

Also note that this can be trivially extended to take other data into account (such as cart lists etc). Also, you can select all users if you want (i.e. K = number of users), but that doesn't always produce meaningful results, and usually picking a reasonably small K is sufficient for good results, and is quicker to compute.

Upvotes: 1

Aravind Yarram
Aravind Yarram

Reputation: 80176

You can find all the information and an implementation (Taste framework) library of common algorithms at here.

Collective Intelligence in Action is another book I can suggest in addition to what other poster had suggested

Upvotes: 2

duffymo
duffymo

Reputation: 308763

Read "Programming Collective Intelligence". It'll give you a taste of it and lots more.

Upvotes: 1

Related Questions