lyst / lyst/lightfm

Call predict() for every user, every item

Open
#566 6 comments 2 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

Hello. I have been trying to use the LightFM predict function for every user and every item in the system. Essentially, my problems occur with supplying the input to predict, as I am unsure what kind of format user_ids and item_ids should take. My code is complex, so I'm going to supply simple examples.

Function definition:
`predict(user_ids, item_ids, item_features=None, user_features=None, num_threads=1)`

Suppose I want to get predictions for 10 users with ids [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] and 10 items with ids [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].

How would I use predict() to get a prediction for every user-item interaction? The following attempts do not work (and numerous others I have tried):

1)
```
user_ids = np.arrange(10)
item_ids = np.arrange(10)
predict(user_ids, item_ids)
```

2)
```
user_ids = np.arrange(10)
item_ids = [ np.arrange(10) for i in range(10) ]
predict(user_ids, item_ids)
```

I am able to use predict inside of a for loop, such as

```
user_ids = np.arrange(10)
item_ids = np.arrange(10)
for i in user_ids:
predict(i, item_ids)
```

However, I would prefer to avoid this, as I can only imagine that calculating everything at once would be more efficient.

Once I figure this out, I will work on incorporating the features.

Thank you for your help!

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 predict(user_ids, item_ids, item_features=None, user_features=None, num_threads=1) entry point and compare its expected input shapes with the two examples and the working loop. Done means clearly documenting how to request predictions for every user-item pair and how feature arguments fit into that usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.