How to generate recommendation for new user..

User 3252 | 3/7/2016, 1:27:13 AM

Hi,

I have created a simple item_popularity recommender model. Using this model, I can generate recommendations for the current users. Question: How do I generate recommendations for a new user 'David'?

 import graphlab as gl

 #Create a simple Sframe
 sf = gl.SFrame({'user_id':['Ann','Ann','Ann','Bob','Bob','Bob','Charlie','Charlie','Charlie'],
                        'item_id': ['Orange','Banana','Mango','Cookie','Chips','Fries','Wine','Beer','Fries'],
                        'rating': [5,1,5,  1,1,5, 1,1,1]})

 #Create a model based on item popularity
 model = gl.popularity_recommender.create(sf,target='rating')   # ranking_factorization_recommender

 # Generate recommendations
 rec = model.recommend()
 rec.print_rows(18)`

Comments

User 1359 | 3/7/2016, 4:20:38 AM

Hello Ram,

You can do this by passing in additional arguments to recommend(). Include the observation, item and user data necessary to describe the new user to the model using the following arguments:

newobservationdata newuserdata newitemdata

PopularityRecommender.recommend


User 3252 | 3/7/2016, 3:52:48 PM

Thank you Dick for suggesting a link to the document.

Unlike other pages, the document does not provide any examples. Could you provide an example? My expectation is that for a new user, the model recommends all the 8 items, with the average score per each item.


User 954 | 3/7/2016, 10:43:37 PM

Hi,

You can use predict() function to pass new User data where the output score for each item is its average score across different users at training time.
`

sf = graphlab.SFrame({'userid': ["0", "0", "0", "1", "1", "2", "2", "2"], 'itemid': ["a", "b", "c", "a", "b", "b", "c", "d"], 'rating': [1, 3, 2, 5, 4, 10, 4, 8]}) m = graphlab.popularityrecommender.create(sf, target='rating') m.recommend(k=4)
Out[54]: Columns: user
id str item_id str score float rank int

Rows: 4

Data: +---------+---------+-------+------+ | userid | itemid | score | rank | +---------+---------+-------+------+ | 0 | d | 8.0 | 1 | | 1 | d | 8.0 | 1 | | 1 | c | 3.0 | 2 | | 2 | a | 3.0 | 1 | +---------+---------+-------+------+ [4 rows x 4 columns]

m.predict(graphlab.SFrame({'userid':["3"],'itemid':["d"]})) Out[55]: dtype: float Rows: 1 [8.0] `


User 3252 | 3/7/2016, 11:44:18 PM

Thank you soroush. I got some errors while predicting. Could you explain why this happens? Using your sframe and model,

#Prediction for new user "3" for Items "d" and "b" : Gives error due to unequal parameter-length m.predict(graphlab.SFrame({'user_id':["3"],'item_id':["d","b"]})) <br>

#Prediction for new users "3" and "5" for Items "d" and "b" : This works OK. m.predict(graphlab.SFrame({'user_id':["3","5"],'item_id':["d","b"]})) <br> #Prediction for new users "3" and "5" for Item "d" and unknown item "z": No error. **Where does it get the rating for item "z"**? m.predict(graphlab.SFrame({'user_id':["3","5"],'item_id':["d","z"]}))