Reputation: 23
I want to give a recommendation to a new user using lightfm.
Hi, I've got model, interactions, item_features. The new user is not in interactions and the only information of the new user is their ratings.(list of book_id and rating pairs)
I tried to use predict() or predict_rank(), but I failed to figure out how. Could you please give me some advice?
Below is my screenshot which raised ValueError..
Upvotes: 0
Views: 3769
Reputation: 1
This worked for me. It explains the process of formatting new user features and generating predictions for them.
fit_partial
can only be used if you want to resume model training from its current state when you have newer interaction data for existing users and items. When you have newer users/items, you should retrain the model.
The existing model can be used to generate predictions for newer users though, the link above explains the process.
Upvotes: 0
Reputation: 66
I was having the same problem, What I did was
Created a user_features matrix (based on their preferences) using Dataset class
dataset = Dataset()
dataset.fit(user_ids,item_ids)
user_features = build_user_features([[user_id_1,[user_features_1]],..], normalize=True)
Provide it during training along with interaction CSR
model = LightFM(loss='warp')
model = model.fit(iteraction_csr,
user_features=user_features)
Create user_feature matrix for new-user using their preference ( in my case genres )
dataset.fit_partial(users=[user_id],user_features=total_genres)
new_user_feature = [user_id,new_user_feature]
new_user_feature = dataset.build_user_features([new_user_feature])
Now predict item rankings with new_user feature
scores = model.predict(<new-user-index>, np.arange(n_items),user_features=new_user_feature)
This gives a pretty decent result for new users but is not as good as the pure CF model.
This is how I implemented it.
Upvotes: 4