lyst / lyst/lightfm

Model prediction scores are zero for all user-item pairs

Open
#662 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
724
PR merge metrics
No merged PRs in 30d

Description

Hi,

When I use the `lightfm.predict` method to predict scores for a fairly large number of users (users ~ 500k, items ~ 5k), the prediction scores returned by `lightfm.predict` are consistently zero for all user-item pairs, ie. np.array([0.0, 0.0, ...]). However, when I try to predict for only a small number of users (~ 500 selected from total users), the scores become non zero, ie. np.array([-54.321, -53.298, ...]).
This is the code I used to calculate scores:
```
scores = model.predict(
user_ids=np.repeat(users, n_items),
item_ids=np.tile(items, n_users),
user_features=user_features_mat,
item_features=item_features_mat,
)
```
where `users` is an `np.array` containing user_ids [0, 2, 3, 4, 6 ..], `items` is an `np.array` containing item_ids [11, 12, 34, 66, ..]. I use `np.repeat` and `np.tile` to properly create arrays matching the user-item pairs for prediction. `n_users` and `n_items` are the number of users and items, respectively.

The reason I'm predicting scores for a large number of users is that I want to get the rank of several particular items against all other items for each selected user. I'm aware of the `predict_rank` method but it's very slow, so I'm trying to replicate that with the `predict` method, which I hope would be much faster.

Anyone seen this type of behaviors before? Any help is much appreciated! Thanks in advance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the LightFM predict method and reproduce the discrepancy using the supplied np.repeat and np.tile inputs, comparing large and small user sets. Check the prediction path for large arrays and verify the result against the smaller case; done means identifying and correcting the zero-score behavior or documenting a confirmed limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.