lyst / lightfm

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

lightfm.evaluation.recall_at_k does not compute the right result #674

Closed dpalbrecht closed 1 year ago

dpalbrecht commented 1 year ago

I am comparing the vectorized prediction routine and recall calculation to LightFM's, and am finding that I can't reproduce LightFM's recall calculation. I am using number of hits at K divided by total number of possible hits, which is how it's implemented in the source.

There might be a problem with the model.predict_rank method since it doesn't seem to produce ranks (as the documentation states) but rather a binary list, which is summed and treated as hits.

If a reproducible example would help, then I'd be happy to provide one. I haven't yet given the effort that'd take and I'm not sure it would be reviewed even if I did.