How to use recommender() method for generating recommendations for new user based on existing data?

User 4540 | 4/9/2016, 6:29:42 AM

Hello, I have used factorizationrecommender.create() to generate a training model. Since I want to find similar new users based on the existing user -items-ratings (10 items rated by every user in data set), I am trying to use recommend() to generate the recommendations of new user. But I am not sure how to use newuserinfo field/parameter to pass the exact same items(item id's) and their ratings for an existing user (because corresponding to each userId in trained model, there are ratings for 10 items so itemId being the key and rating its value) to verify if the recommendation method I used, returns the user with same ratings(to be categorized as a similar user based on item preferences/ratings). //Say a user with userId 100 isn't in trained model so a new user. Here I plan to pass an existing userId's rating for a particular ItemId:X. res=graphlab.factorizationrecommender.create(data,userid='UserId', itemid='ItemId',target='Rating') newuserinfo=graphlab.SFrame({'UserId':100,'ItemId':['X'],'Rating':3})
res.recommend(users=100,newuserdata=newuserinfo) This results in an error. Also, can I pass all ItemIds and their respective ratings (for a particular existing user ) in newuserdata in recommend()? Can someone advice how to proceed,if this isn't the correct way?

Comments

User 19 | 4/9/2016, 4:42:16 PM

Hi schawla,

Sorry you're having trouble here.

The following example works for me. It's close to yours, but notice that I pass in a list of the new users that I want to make recommendations for. Can you check whether it works for you as well?

import graphlab data = graphlab.SFrame({'user_id': ["Ann", "Ann", "Ann", "Brian", "Brian", "Brian"], 'item_id': ["Item1", "Item2", "Item4", "Item2", "Item3", "Item5"], 'rating': [1, 3, 2, 5, 4, 2]}) m = graphlab.factorization_recommender.create(data, target='rating') newdata = graphlab.SFrame({'user_id': ['Chris'], 'item_id': ["Item1"], 'rating': [3]}) m.recommend(users=['Chris'], new_observation_data=newdata)

Cheers, Chris


User 4540 | 4/9/2016, 8:00:52 PM

Hello Chris, Thank you for helping. I tried to do in similar way for my code. So, it executes fine,with no errors but in output for recommend(), excludes that particular item X and its rating but instead shows the other 10 items, ratings. Also, there are 10 items so should I pass all the 10items and respective rating col as arguments to newobservationdata. Anyhow the main objective of doing this is to check if a new user is similar to the existing ones. So one more thing to clarify, since the aim is to find similar users based on the existing user's items-ratings. So, the recommend() method used to generate recommendation for new user should return the same items ratings that I pass as an argument for a particular existing user. Am I correct on this understanding?


User 4540 | 4/11/2016, 4:41:07 AM

Hello Chris, Yes, your code works well. And I did similar for mine too . But can you explain this output especially the score and rank columns. On what basis each item is ranked ? And how does it depict that this user(Chris) is similar to Ann who rated the Item1 as 3. +---------+---------+---------------+------+ | userid | itemid | score | rank | +---------+---------+---------------+------+ | Chris | Item2 | 4.16664262613 | 1 | | Chris | Item3 | 3.17410623034 | 2 | | Chris | Item4 | 3.15834518274 | 3 | | Chris | Item5 | 1.1756251653 | 4 | +---------+---------+---------------+------+