# Item based and user based recommendation difference in Mahout

I would like to know how exactly mahout user based and item based recommendation differ from each other.

It defines that

User-based: Recommend items by finding similar users. This is often harder to scale because of the dynamic nature of users.

Item-based: Calculate similarity between items and make recommendations. Items usually don't change much, so this often can be computed off line.

But though there are two kind of recommendation available, what I understand is that both these will take some data model ( say 1,2 or 1,2,.5 as item1,item2,value or user1,user2,value where value is not mandatory) and will perform all calculation as the similarity measure and recommender build-in function we chose and we can run both user/item based recommendation on the same data ( is this a correct assumption ?? ).

So I would like to know how exactly and in which all aspects these two type of algorithm differ.

You are correct that both models work on the same data without any problem. Both items operate on a matrix of user-item ratings.

In the user-based approach the algorithm produces a rating for an item i by a user u by combining the ratings of other users u' that are similar to u. Similar here means that the two user's ratings have a high Pearson correlation or cosine similarity or something similar.

In the item-based approach we produce a rating for i by u by looking at the set of items i' that are similar to i (in the same sense as above except now we'd be looking at the ratings that items have received from users) that u has rated and then combines the ratings by u of i' into a predicted rating by u for i.

The item-based approach was invented at Amazon to address their scale challenges with user-based filtering. The number of things they sell is much less and much less dynamic than the number of users so the item-item similarities can be computed offline and accessed when needed.

Item Based Algorithm

for every item i that u has no preference for yet

for every item j that u has a preference for

compute a similarity s between i and j

add u's preference for j, weighted by s, to a running average

return the top items, ranked by weighted average


User Based Algorithm

for every item i that u has no preference for yet

for every other user v that has a preference for i

compute a similarity s between u and v

add v's preference for i, weighted by s, to a running average

return the top items, ranked by weighted average


Item vs User based:

1) Recommenders scale with the number of items or users they must deal with, so there are scenarios in which each type can perform better than the other

2) Similarity estimates between items are more likely to converge over time than similarities between users

3) We can compute and cache similarities that converge, which can give item based recommenders a performance advantage

4) Item based recommenders begin with a list of a user's preferred items and therefore do not need a nearest item neighborhood as user based recommenders do

• Fair warning: Links aren't accepted as answers on this site. I recommend editing or deleting before you get any downvotes! Dec 4 '14 at 18:56
• most likely there is a typo in "user-based algorithm" - fourth line should start with "add u's preference for i..." May 27 '17 at 16:26
• @BernardoAflalo I dont think its a typo, you add preference for all the v, and then take a weighted average Mar 7 '18 at 6:39