question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

same prediction for every user

See original GitHub issue

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 ?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
clementechiucommented, Oct 22, 2019

Hey @RaphLot ! I’m having a similar problem. Did you manage to solve it? What did you do? I’d appreciate any help. Thanks in advance!

0reactions
clementechiucommented, Apr 3, 2020

No, that means there’s something wrong with your model or data. You should have different recommendations, otherwise using a model is pointless.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my Neural network gives same prediction for every ...
I am trying to create a neural network that takes 294 inputs and predicts which of the inputs has the probability to be...
Read more >
predict gives the same output value for every image (Keras)
When all the predictions are giving exact the same value you know that your model is not learning thus something is wrong!
Read more >
How to Make Predictions with Keras - Machine Learning Mastery
Once you choose and fit a final deep learning model in Keras, you can use it to make predictions on new data instances....
Read more >
How to use a model to do predictions with Keras - ActiveState
Keras Model Components ... It's also possible to save all or some of the components to disk in a 'final' model for future...
Read more >
model.predict() always different for same image - Google Groups
Now, I want to load/restore this model and make some predictions, i.e. feed the network with some images. But every time I load...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found