benfred / implicit

Fast Python Collaborative Filtering for Implicit Feedback Datasets
https://benfred.github.io/implicit/
MIT License
3.57k stars 612 forks source link

Excluding some negatives from training #550

Open mmosc opened 2 years ago

mmosc commented 2 years ago

Hi!

First of all, thank you for this great library!

I'm currently using it for extending and comparing some matrix factorisation models for recommendation. I am working on the LFM-2b dataset.

For design reasons, part of my interaction matrix (or rather an extended version of it) consists of a block of zeros, which however should NOT be considered while training.

To explain things better, I want to train on a matrix like this: inter_matrix with A, B, C being sparse matrices and 0 being an empty matrix. The model should NOT use the entries of the bottom-right block for training.

In my understanding, with respect to ALS, this would mean that in the cost function given by als the sum over u, i should leave the elements of the lower-right block out.

If we imagine to be using BPR instead, the negative samples should never belong to this block.

Is there a way to do this?

Thanks :) Marta