Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to combine interaction matrices #176

Closed
laszbalo opened this issue May 11, 2017 · 15 comments
Closed

Best way to combine interaction matrices #176

laszbalo opened this issue May 11, 2017 · 15 comments

Comments

@laszbalo
Copy link

Hi,

I'd like to build a website, where users can like items and after they liked an item, they can refine what features of that item they liked. (one item can have max ~50 features)
On top of the above explicit feedback, I'd like to incorporate some implicit feedback, like whether a user clicked on an item, percentage of photos viewed, time spent on the item's profile, etc.

Since LightFM was designed to use only one interaction matrix, I should have somehow combine them. On possible way forward would entail the following:

  1. Train a model with implicit click-through data (could be dense)
  2. Train a model with explicit item likes (sparse)
  3. Train a separate model for each features; same size as the above two matrix; for every feature f the value is 1 if user u liked feature f of item i (sparser)

Now I can call predict on all the above models, and average their results. I can also use weighted average, e.g. models based on explicit likes get higher weights, etc. Also, I have not put much thought into it yet, but it might be possible to learn the weights for the models automatically.

Is there a better/more efficient way to combine the interaction matrices?

Reading through the LightFM paper, Factorisation Machines might suit my needs better, because unlike LightFM, they can solve for multiple interaction matrices.
Therefore, does it make sense to attempt to use LightFM in my situation?

@JasonTam
Copy link
Contributor

You can also try encoding the explicit interactions as user features. In that sense, the final user representation will be characterized by the sum of a user-specific embedding and the embeddings associated with liking various movies.

@laszbalo
Copy link
Author

laszbalo commented May 11, 2017

@JasonTam Thanks for your answer. I was considering the same thing, but I was worried that by doing so I will add a lot of bias to the recommender. In other words, the most telling latent features to predict whether a user has viewed an item, are the explicit feedback features. The lack of independence among user features and the interaction matrix is not a problem in practice? Am I missing something here?

@maciejkula
Copy link
Collaborator

You can combine the explicit and implicit feedback data in the model by giving higher weights to interactions that have explicit likes. This is somewhat crude, but should work. I don't have a firm opinion on how to treat feature likes.

A more principled approach to implicit + explicit data is something like this paper. I have a related implementation here via the truncated regression loss. In your case, you'd treat the implicit likes as the truncation variable and explicit likes as the truncated ratings.

@laszbalo
Copy link
Author

@maciejkula Thanks for the info.

giving higher weights to interactions that have explicit likes

Let me get this straight. I have to do this outside of the realm of LightFM, right? Like in the way I outlined above. In the case of one implicit and one explicit interaction matrices, I have to train two separate models, get a prediction from each, and take the weighted average of the predictions, where higher weight goes to the prediction obtained from the model trained with the explicit data.

@JasonTam
Copy link
Contributor

JasonTam commented May 12, 2017

Your implicit interactions would just be a boolean of whether a user has interacted with an item or not. Then you can use your explicit data to fill in sample_weight (https://github.com/lyst/lightfm/blob/master/lightfm/lightfm.py#L377) . Ex) you might give twice as much weighting to an interaction if a user has explicitly liked an item. The actual values you choose for sample_weight is then a hyper-parameter.

disclaimer: I haven't found sample_weight to be useful in my own uses lol

@arita37
Copy link

arita37 commented Dec 19, 2017

I have this dataset :
Nuser(100,000) >> Mitem (100)

For some reasons, Convergence + AUC is better
without item feature, user feature.
iteam and user are category and item incorporate rating from users.....

Any idea why pure CF is better than Hybrid ?

@maciejkula
Copy link
Collaborator

Copying my answer from #225:

If your hybrid model performs worse than a pure CF model, the following may be helpful.

  1. Make sure your features are appropriately scaled.
  2. If your features are continuous, consider discretization.
  3. Make sure you don't drop per-item or per-user features. Again, have a look at the notes section.
  4. Consider inverse-frequency weighting of your features.

@arita37
Copy link

arita37 commented Dec 19, 2017 via email

@maciejkula
Copy link
Collaborator

In the feature matrix, give low values to common features, 1.0 / count_of_occurrence for example.

@arita37
Copy link

arita37 commented Dec 19, 2017 via email

@maciejkula
Copy link
Collaborator

No, I am suggesting this for categorical features. Instead of inserting a 1, insert the weight.

I imagine you could, depending on what task is important to you.

@arita37
Copy link

arita37 commented Dec 20, 2017 via email

@maciejkula
Copy link
Collaborator

  1. Even if it is one-hot encoding, you can always insert some other value (0.5, 0.001) instead of the 1.
  2. I mean that you should use values other than 1 in the item/user feature matrices. If you look at scipy sparse matrices you will see that they have a data array that holds the values for the non-zero entries.

For a general overview of inverse frequency weighting, you could read about the TF-IDF technique.

@arita37
Copy link

arita37 commented Dec 30, 2017 via email

@SimonCW
Copy link
Collaborator

SimonCW commented Jan 23, 2021

I’m closing this issue because it has been inactive for a long time. If you still encounter the problem, please open a new issue.

Thank you!

@SimonCW SimonCW closed this as completed Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants