Dataset build_interactions returns interaction values other than 0 and 1
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 724
- PR merge metrics
- No merged PRs in 30d
Description
I am using lightfm Dataset().build_interactions() to create interactions matrix between users and items(phones in this case). I'm using the number of times a user has viewed a phone (pageviews) as weights:
`import pandas as pd`
`df_interactions = pd.DataFrame({"user_id_num":[0, 0, 1, 2, 2, 2, 3], "phone_id_num":[0, 1, 2, 0, 0, 1, 2], "pageviews":[1, 3, 4, 1, 1, 5, 7]}) `
Then I create a (user_id_num, phone_id_num, pageviews) column in the df_interactions:

As you can see there are two interactions with the same (user_id, phone id) (2,0). When I feed this to the Dataset class's build_interactions method, it creates the following interactions and weights matrices:

I was expecting to see all 1's in the interactions matrix and the sum of the weights in the weights matrix. But here you can see that a 2 in the interactions matrix. I'm wondering whether this is a feature or a bug?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied pandas reproducer and start with Dataset.build_interactions(), focusing on how duplicate (user_id, item_id) rows are represented in the interactions and weights matrices. Confirm whether the observed value of 2 is intended behavior; done means resolving the duplicate-row handling so it matches the documented contract or clearly documenting the existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100