LightFM does the training set need to be the same size as the test set

0 votes

I'm working on a pure collaborative filtering model in LightFM using a simple user-item matrix.

When I have a training matrix that has more rows than the test matrix, I encounter this error: "Incorrect number of features in user_features"

It seems this is caused by line 789 in lightfm.py:

if not user_features.shape[1] == self.user_embeddings.shape[0]:
    raise ValueError('Incorrect number of features in user_features')

Investigating this - it looks like it is being caused by line 778 in lightfm.py:

n_users, n_items = test_interactions.shape

Which suggests the size of the test dataset should match the train. And making them the same size does fix my error.

How can I persuade LightFM to let me have train and test datasets of different sizes?

Oct 5, 2018 in Python by eatcodesleeprepeat
• 4,710 points
849 views

1 answer to this question.

0 votes

I would change the wording. Often in ML, the rows are the samples and in this interpretation your single row-sample is a tuple or something similar (user, item, value). The number of rows in test and train surely has no limitation! But there is one in terms of dimensions. So only in terms of dimensions (which users and which items are observed) those datasets need a 1:1 correspondence. That's maybe a strong assumption, but you can imagine the problem predicting user 11, where there was no user 11 in training (there is no latent-vector which was build)

answered Oct 5, 2018 by Priyaj
• 58,020 points

Related Questions In Python

0 votes
1 answer

In LightFM does the training set need to be the same size as the test set?

I would change the wording. Often in ML, ...READ MORE

answered Sep 21, 2018 in Python by charlie_brown
• 7,720 points
759 views
0 votes
1 answer
0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by aryya
• 7,460 points
1,413 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,270 points
2,165 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8, 2019 in Python by rajesh
• 1,270 points
2,099 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP