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.

Integration of User- & Item-Features

See original GitHub issue

Hi,

I have a problem with integrating user- and item-features. After some research I now know that I have to concatenate my user/item-feature matrix with an identity matrix. After doing this, my user-matrix looks the following: grafik

When I know integrate this matrix in csr-format into my model fit it with (user_features = my_features) export the top-N recommendation using the predict function (with user_features agian!) I get the following precision when evaluating it. figure_1 The blue line here is without adding User_features!

What is going wrong there? 😦

My code looks like this:

NUM_COMPONENTS = 10
NUM_EPOCHS = 20
learn_rate = 0.02
NUM_THREADS = 10

model = LightFM(loss = 'bpr, no_components=NUM_COMPONENTS, learning_rate=learn_rate)

model.fit(train, epochs=NUM_EPOCHS, num_threads=10, user_features=user_features)

` after doing this I export the top-N for every User in my testset:

recommendations = list()
n_users, n_items = test.shape
for user_id in np.arrange(n_users):
     scores = model.predict(user_id, np.arange(n_items), num_threads=10, user_features=user_features)
     top_items_list = np.argsort(-scores)[:20].tolist()
     productids = itemgetter(*top_items_list)(products)
     userid = customers[user_id]
     recommendations.append({'UserID': userid, 'Empfehlungen': productids, 'Scores': np.sort(scores)[::-1 [:20].tolist()})

Here customers are the real labels of the customers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
maciejkulacommented, Oct 8, 2017

This looks fine, as far as I can tell. Try lowering the learning rate!

1reaction
KJeniacommented, Apr 3, 2019

hi! I couldn’t understand one thing, after model.fit could I make model.predict for users_id which was’n in model fit? for example, I fit the model for user_id = [1,2,3] and I want make prediction for user_id=4, is it possible do it without retrain the model? p.s. of course there is no new user or item features for predicted user thanks for suggestion

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Customer and Product Features in Recommender ...
Assuming that extra user features have unique values per user and extra item features have a unique value per item, one can represent...
Read more >
The 7 Variants of Matrix Factorization For Collaborative Filtering
A straightforward matrix factorization model maps both users and items to a joint latent factor space of dimensionality D — such that user-item...
Read more >
Attribute-Aware Recommender System Based on ... - Frontiers
User -relevant attributes determine the characteristics of a user, such as “age,” “gender,” “education,” etc. In contrast, item-relevant ...
Read more >
Recommender Systems Based on Collaborative Filtering ...
A CF system generates recommendations based on the relationships and similarities between users or items [17]. These relations are inferred from the user-item...
Read more >
The anatomy of high-performance recommender systems
The basic models for recommender systems work with two kinds of data: user-item interactions, such as ratings and buying behavior, and attribute ...
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