lyst / lyst/lightfm

Dataset build_interactions returns interaction values other than 0 and 1

Open
#482 1 comment 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

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:

![Screenshot 2019-08-08 at 10 54 03](https://user-images.githubusercontent.com/25546598/62693882-33cbba80-b9cb-11e9-9270-011a061670e1.png)

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:

![Screenshot 2019-08-08 at 11 00 12](https://user-images.githubusercontent.com/25546598/62694165-bb192e00-b9cb-11e9-80a7-6520f05562eb.png)

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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.