lyst / lightfm

A Python implementation of LightFM, a hybrid recommendation algorithm.
Apache License 2.0
4.66k stars 679 forks source link

Recommender System with RFM ratings to put into Interaction matrix #693

Open rajatrautela opened 1 year ago

rajatrautela commented 1 year ago

I am trying to use LightFM for recommending the places to transact at. I have used Recency, Frequency and Monetary (RFM) to calculate the interactions between a user and a shop. I am putting these RFM interaction into Interaction matrix. How do i go about in such a case? I am using BPR loss function and have tried parameter tuning. It gives good recall and AUC score here... But the issue is that the stores whose Interaction ratings are generally high... Are being recommended less. The actual life recall doesn't match. Please help how to proceed if I am making any mistake in creating the interaction matrix.

Natsuhadder commented 1 year ago

Hello , have you tried to normalize your RFM scores in the interaction matrix or change the values of your hyperparameters to see if there are any improvements ?

rajatrautela commented 1 year ago

The RFM scores were binned and I got ratings ranging from minimum 4 to maximum 18. Do you suggest I try to still normalize it into values in range 0 to 1? I have tried changing the hyperparameters, didn't work. However I also noticed that after predictions, the values I get for each interaction are negative. Is the negative value normal? Or is it due to some issue?

Natsuhadder commented 1 year ago

The negative scores that you get in the predictions are normal to be observed , but i think that's abnormal if u have all the scores negatives for all your prédictions. What is the loss function you are using ?

What concerns the question of normalization , i think that the model doesn't capture well the RFM scores as there are many values (14) , u can try to either normalize them to range in 0-1 , or create a sort of bins for ur values and give for each bin a value. Also it's weird that u don't have 0's in your interaction matrix , don't you have some users that have never interacted with a particular shop ?

rajatrautela commented 1 year ago

For such users the interaction would be null, I assume. Also, the loss function I used is BPR

rajatrautela commented 1 year ago

I will try it using the normalization you suggested. Thanks. Hope it works.

Natsuhadder commented 1 year ago

You can try the WARP loss fucntion also if you want your already positive items to be ranked higher than negative items in the training process.

The interaction matrix in the Lightfm model doesn't handle null values, they are rather transformed into zero values.

rajatrautela commented 1 year ago

When we put the interaction matrix, I was of the idea that these Null values would be filled in during prediction. Like in Collaborative filtering. It's like I would like the non interacted shops to be recommended based on similarity with other users who have interacted with those shops.

Natsuhadder commented 1 year ago

Yes , i actually have the same problem , i would like to improve the lightfm class in order to support a non negative matrix factorization. But the current lightfm doesn't support this type of problematic.

rajatrautela commented 1 year ago

Alright. Thank you so much for the help :)