0

In Graphlab, I am trying to use recommend() method, to see how it provides recommendation for a new user(user_id) which isn't present in the trained model prepared from give dataset. Since the aim is to determine similar users through this recommendation model used, so I plan to pass the new_user_data in recommend(), but with exact same item- ratings of an existing user to check if it should returns the same ratings. Here is what I am doing:

(data is the dataset containing UserIds, ItemIds and Rating columns) (say 104 is a new UserId which isn't in data set)

result=graphlab.factorization_recommender.create(data,user_id='UserId',     
item_id='ItemId',target='Rating')   
new_user_info=graphlab.SFrame({'UserId':104,'ItemId':['x'],'Rating':9})   
r=result.recommend(users=104,new_user_data=new_user_info)

I am getting an error:

raise exc_type(exc_value)

TypeError: object of type 'int' has no len()

Can anyone help as to how to use recommend() method for new user ?

1 Answers1

1

Which of the lines give you the exception? I think that you have problems with your SFrame creation and with your usage of the .recommend() method.

new_user_info=graphlab.SFrame({'UserId':104,'ItemId':['x'],'Rating':9})   
# should be
new_user_info=graphlab.SFrame({'UserId':[104],'ItemId':['x'],'Rating':[9]})   
# construct SFrames from a dictionary where the values are lists

and

r = result.recommend(users=104,new_user_data=new_user_info)
# should be:
r = result.recommend(users=[104],new_user_data=new_user_info)
# users is a list, not an integer
Guy Rapaport
  • 318
  • 3
  • 11