lyst / lyst/lightfm

Finding the precision and auc scores.

Open
#369 12 comments 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 building a recommendation model for user-article dataset where each interaction is represented by 1.

model = LightFM(loss='warp', item_alpha=ITEM_ALPHA, user_alpha=USER_ALPHA, no_components=NUM_COMPONENTS, learning_rate=LEARNING_RATE, learning_schedule=LEARNING_SCHEDULE)

model = model.fit(train, item_features=itemf, user_features=uf, epochs=NUM_EPOCHS, num_threads=NUM_THREADS)

print("train shape: ",train.shape) print("test shape: ",test.shape)

train shape: (25900, 790)
test shape: (25900, 790)

My predict model looks like this:

predictions = model.predict( user_id, pid_array, user_features=uf, item_features=itemf, num_threads=4)

where pid_array are indexes of number of items

train_precision = precision_at_k(model, train, k=10).mean()

I am trying to predict the precision and subsequently want auc score also. But I get this error.

Traceback (most recent call last):
File "new_light_fm.py", line 366, in
train_precision = precision_at_k(model, train, k=10).mean()
File "/home/nt/anaconda3/lib/python3.6/site-packages/lightfm/evaluation.py", line 69, in precision_at_k
check_intersections=check_intersections,
File "/home/nt/anaconda3/lib/python3.6/site-packages/lightfm/lightfm.py", line 807, in predict_rank
raise ValueError('Incorrect number of features in item_features')
ValueError: Incorrect number of features in item_features

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

Start in lightfm/evaluation.py at precision_at_k and follow its call into lightfm/lightfm.py predict_rank, using the reported train, itemf, and user-feature shapes as the reproduction case. Determine why the feature count check fails and document a verified way for precision_at_k and AUC evaluation to run successfully.

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
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.