lyst / lyst/lightfm

same prediction for every user

Open
#320 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.1k
Forks
724
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am really new to recommender system and to lightfm.
I am trying to see what the model I build recommender for all my users (considering all my items), but I keep getting the very same prediction (recommendation) for every single user.

Here the code I used :
```
param = {'no_components': 314,
'learning_schedule': 'adagrad',
'loss': 'warp-kos',
'learning_rate': 0.010372998003563394,
'item_alpha': 1.0041412735137758e-06,
'user_alpha': 4.364266509627352e-09,
'max_sampled': 20,
'num_epochs': 57}
num_epochs = param.pop("num_epochs")
model = LightFM(**param)

model = model.fit(interaction,
user_features=user_features,
item_features=item_features,
epochs=num_epochs,
num_threads=4)

mapp = dataset.mapping()
dict_user_id = mapp[0]
dict_item_id = mapp[2]

pid_array = np.arange(len(dict_item_id), dtype=np.int32)
d_user_pred = {}

for user in dict_user_id.keys():
d_user_pred[user] = []

for index, user_id in dict_user_id.items():
sys.stdout.write("\rProcessing user " + str(index + 1) + "/ " + str(len(dict_user_id)))
sys.stdout.flush()
scores = model.predict(index, np.arange(len(dict_item_id)),
user_features=user_features,
item_features=item_features)
top_items = item['item_id'][np.argsort(-scores)]
d_user_pred[index] = top_items
```

My dataset shape is : 20.741 users and 2530 items.
Also, I have really low p@k, maybe that the problem ?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the model.fit and model.predict calls shown in the issue, then inspect dataset.mapping(), the user and item index ranges, and the user_features and item_features passed to prediction. Compare score arrays and mapped item IDs for several users. Done means identifying why predictions are identical and documenting or correcting the behavior with evidence from the 20,741-user, 2,530-item dataset.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
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.