bilibilimaster
bilibilimaster

Reputation: 21

about lightFM,How to embed the feature matrix and recommend new projects to user

my goal is to fit a model that suit my personal DATA,and I have processed the data and made it three files : interaction matrix(394*2188); item feature matrix(5241*5241); user feature matrix(1043*1043); I have converted all of them into sparse matrix, and my both feature matrixs contain more content than interactions. when I fit the model by these data and make prediction,there are my codes and errors: codes:

model = LightFM(loss='warp')
model.fit(data,item_features=items,user_features=users,epochs=30, num_threads=2)
evaluation.auc_score(model,data)

errors: raise ValueError('Incorrect number of features in item_features') ValueError: Incorrect number of features in item_features

  1. how can I convert data that the interaction matrix’s users and items are less than features matrix
  2. how can I recommend new and old items to all users(including the new)

Upvotes: 2

Views: 1812

Answers (1)

Parzie
Parzie

Reputation: 220

I'm going to start by explaining why you're getting the error: raise ValueError('Incorrect number of features in item_features') ValueError: Incorrect number of features in item_features

This error has likely occurred because of the last line of your code

   evaluation.auc_score(model,data)

If you check the docs here: https://lyst.github.io/lightfm/docs/lightfm.evaluation.html

You'll see that you need to also provide user_features=users and item_features=items as parameters to auc_score (When you're using user and item features in model.fit)

i.e. a fixed version may look like

      evaluation.auc_score(model, data, user_features=users and item_features=items)

Once you fix that error, we can take a closer look at your additional 2 questions.

Upvotes: 2

Related Questions